注册 登录
编程论坛 jQuery论坛

ASP.NET Ajax 1.0 问题:如何解决UpdatePanel控件之外的控件接收不到UpdatePanel控

foshan 发布于 2007-03-25 16:04, 1657 次点击

ASP.NET Ajax 1.0 问题:如何解决UpdatePanel控件之外的TextBox控件接收不到UpdatePanel控件之内Button控件的事件?(用了 <Triggers> 也解决不了问题……)

以下是源文件:

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server" />
<div>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:Button ID="Button1" runat="server" Text="Button" OnClick="Button1_Click" />
<asp:FileUpload ID="FileUpload2" runat="server" /><br />
&nbsp;<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="Button1" EventName="Click" />
</Triggers>
</asp:UpdatePanel>
<asp:Button ID="Button2" runat="server" Text="Button" OnClick="Button2_Click" />
<asp:FileUpload ID="FileUpload1" runat="server" />
<br />
<asp:TextBox ID="TextBox2" runat="server"></asp:TextBox></div>
</form>
</body>
</html>

***************************************************************************

protected void Button1_Click(object sender, EventArgs e)
{
TextBox1.Text = "88";
TextBox2.Text = "99";
}
protected void Button2_Click(object sender, EventArgs e)
{
TextBox1.Text = "AA";
TextBox2.Text = "BB";
}

1 回复
#2
foshan2007-03-25 16:16
上述的代码,在运用后,当点击 Button1 控件时,UpdatePanel控件之外的TextBox2控件的Text并没有变成“99”,而仅是UpdatePanel控件之内的TextBox1控件的Text变成“88”。
如何才能实现:点击 Button1 控件时,UpdatePanel控件之外和之内的两个TextBox2控件的Text变成相应的内容???
1