前台:
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="test2.aspx.cs" Inherits="WebApplication1.test2" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<asp:UpdatePanel runat="server" ID="updatePanel2">
<ContentTemplate>
<asp:TextBox ID="txtCompanyCd" runat="server" OnTextChanged="txtChanged" AutoPostBack="true"></asp:TextBox>
<asp:TextBox ID="txtUserNm" runat="server" ></asp:TextBox>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="txtCompanyCd" EventName="textChanged" />
</Triggers>
</asp:UpdatePanel>
</div>
</form>
</body>
</html>
后台:
protected void txtChanged(object sender, EventArgs e)
{
txtUserNm.Text = "test";
}
错误提示的时候,注意要用:
ScriptManager.RegisterStartupScript(this.updatePanel2, this.GetType(), "sucess", "alert('登録完了しました。')", true);
不能用: this.ClientScript.RegisterStartupScript(GetType(), "getUserInfo", “alert(3434)”, true);