An example of user name detection when registering is implemented using updatepanel local refresh
- 2020-12-13 18:57:17
- OfStack
Local refreshes are achieved by placing controls into updatepanel.
Foreground code:
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager> // Must have and write in updatepanel In front of the
<asp:updatepanel runat="server" id="updatepanel1">
<contenttemplate>
<asp:textbox runat="server" id="txtname"></asp:textbox>
<asp:button runat="server" id="btn" text=" detection " onclick="btn_click"></asp:button>
<asp:label runat="server" id="tip"></asp:label>
</contenttemplate>
</asp:updatepanel>
Background code:
protected void btn_Click(object sender, EventArgs e)
{
if (this.txtname.Text == "user1")
{
this.tip.Text = " The user name already exists ";
}
else
{
this.tip.Text = " User name available ";
}
}