源码网商城,靠谱的源码在线交易网站 我的订单 购物车 帮助

源码网商城

使用updatepanel局部刷新实现注册时对用户名的检测示例

  • 时间:2022-04-29 07:50 编辑: 来源: 阅读:
  • 扫一扫,手机访问
摘要:使用updatepanel局部刷新实现注册时对用户名的检测示例
通过将控件放入到updatepanel中,实现局部刷新。 前台代码:
[u]复制代码[/u] 代码如下:
<asp:ScriptManager ID="ScriptManager1" runat="server"> </asp:ScriptManager>     //必须有且写在updatepanel前面 <asp:updatepanel runat="server" id="updatepanel1"> <contenttemplate>   <asp:textbox runat="server" id="txtname"></asp:textbox>   <asp:button runat="server" id="btn" text="检测" onclick="btn_click"></asp:button>   <asp:label runat="server" id="tip"></asp:label> </contenttemplate> </asp:updatepanel>
后台代码:
[u]复制代码[/u] 代码如下:
protected void btn_Click(object sender, EventArgs e) {   if (this.txtname.Text == "user1")   {     this.tip.Text = "用户名已存在";   }   else   {     this.tip.Text = "用户名可用";   } }
  • 全部评论(0)
联系客服
客服电话:
400-000-3129
微信版

扫一扫进微信版
返回顶部