通過將控件放入到updatepanel中,實現局部刷新。
前臺代碼:
復制代碼 代碼如下:
<asp:ScriptManager runat="server">
</asp:ScriptManager> //必須有且寫在updatepanel前面
<asp:updatepanel runat="server">
<contenttemplate>
<asp:textbox runat="server"></asp:textbox>
<asp:button runat="server" text="檢測"></asp:button>
<asp:label runat="server"></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 = "用戶名可用";
}
}
新聞熱點
疑難解答
圖片精選