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

早上好,给您新鲜的问候,温暖的祝福,清晨,美好的开端,祝您今天精神振奋,精力充沛,心情愉快,一切都很好!

通过将控件放入到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 = "用户名可用";
  }
}

以上就是使用updatepanel局部刷新实现注册时对用户名的检测示例。交际的目的就是为了能与更多的人进行交往,能够更快地提升自己,能够获得别人更多的帮助。而要想让别人喜欢与你交往,就要树立自己的良好形象,用形象采打造出成功的交际。更多关于使用updatepanel局部刷新实现注册时对用户名的检测示例请关注haodaima.com其它相关文章!

标签: updatepanel