AJAX TextChanged 事件練習
============ 下面是 說明的部份 ============================
當TextBox1輸入值後,當focus離開TextBox1後,會去呼叫後台的C# CODE
C# CODE就看需要什麼資料再自己加就好
多筆資料要注意接資料的控制項
============ 下面是 HTML 的部份 ==========================
<body>
<form id="form1" runat="server">
<div>
<asp:ScriptManager ID="ScriptManager1" runat="server" >
</asp:ScriptManager>
<table class="style1">
<tr>
<td class="style2">
key in :
</td>
<td>
<asp:TextBox ID="TextBox1" runat="server"
ontextchanged="TextBox1_TextChanged" AutoPostBack="True" style="margin-left: 0px"></asp:TextBox>
</td>
</tr>
<tr>
<td class="style2">
data out :
</td>
<td>
<asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<asp:TextBox ID="TextBox2" runat="server"></asp:TextBox>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="TextBox1" EventName="TextChanged" />
</Triggers>
</asp:UpdatePanel>
</td>
</tr>
</table>
</div>
</form>
</body>
============ 下面是 C# 的部份 ==========================
protected void TextBox1_TextChanged(object sender, EventArgs e)
{
TextBox2.Text = TextBox1.Text;
////System.Web.UI.ScriptManager.RegisterStartupScript(this, this.GetType(), "opennewwindow", "alert('彈出框內容!');", true);
}
沒有留言:
張貼留言