当前位置: 移动技术网 > IT编程>开发语言>.net > 使用updatepanel局部刷新实现注册时对用户名的检测示例

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

2017年12月12日  | 移动技术网IT编程  | 我要评论
通过将控件放入到updatepanel中,实现局部刷新。前台代码:复制代码 代码如下:<asp:scriptmanager id="scriptmanager1" r

通过将控件放入到updatepanel中,实现局部刷新。
前台代码:

复制代码 代码如下:

<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>

后台代码:

复制代码 代码如下:

protected void btn_click(object sender, eventargs e)
{
  if (this.txtname.text == "user1")
  {
    this.tip.text = "用户名已存在";
  }
  else
  {
    this.tip.text = "用户名可用";
  }
}

如您对本文有疑问或者有任何想说的,请点击进行留言回复,万千网友为您解惑!

相关文章:

验证码:
移动技术网