使用updatepanel局部刷新实现注册时对用户名的检测示例
使用updatepanel局部刷新实现注册时对用户名的检测示例
发布时间:2016-12-29 来源:查字典编辑
摘要:通过将控件放入到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="检测"></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 = "用户名可用";

}

}

推荐文章
猜你喜欢
附近的人在看
推荐阅读
拓展阅读
相关阅读
网友关注
最新asp.net教程学习
热门asp.net教程学习
编程开发子分类