·您现在的位置: 云翼网络 >> 文章中心 >> 网站建设 >> 网站建设开发 >> ASP.NET网站开发 >> updatepanel局部刷新功能,实现注册时对用户名的检测

updatepanel局部刷新功能,实现注册时对用户名的检测

作者:佚名      ASP.NET网站开发编辑:admin      更新时间:2022-07-23

updatepanel局部刷新功能,实现注册时对用户名的检测

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 = "用户名可用";   }}