您的位置:首页 > 其它

AJAX之UpdatePanel 篇

2011-05-19 13:50 253 查看
前台:

<%@ 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);
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: