我的页面上有两个面板。当第一个面板更新时,执行第一个面板的代码。当第二个面板更新(文本更改)时,执行第一个面板的代码。我可以单击第二个面板的按钮并执行正确的代码,但是为什么在更改第二个面板时不会触发正确的触发器?
在开发机器上的 Windows Server 2008R2 和 Windows 7 IIS 上都试过这个。
TESTPANEL.ASPX
<%@ Page Language="vb" AutoEventWireup="false" CodeBehind="testpanel.aspx.vb" Inherits="tpanels.testpanel" %>
<!DOCTYPE html>
<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:Button runat="server" ID="btn1" Text="BTN1" OnClick="btn1_click" />
<asp:Button runat="server" ID="BTN2" Text="BTN2" OnClick="btn2_Click" />
<asp:UpdatePanel runat="server" ID="pnl1" UpdateMode="Conditional" ChildrenAsTriggers="False">
<ContentTemplate>
<asp:TextBox runat="server" ID="txt1" value="start"></asp:TextBox>
<asp:TextBox runat="server" ID="txt2" value="start"></asp:TextBox>
</ContentTemplate>
</asp:UpdatePanel>
<asp:UpdatePanel runat="server" ID="pnl2" UpdateMode="Conditional" ChildrenAsTriggers="False">
<ContentTemplate>
<asp:TextBox runat="server" ID="txt3" value="start"></asp:TextBox>
<asp:TextBox runat="server" ID="txt4" value="start"></asp:TextBox>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="BTN2" EventName="click" />
</Triggers>
</asp:UpdatePanel>
</div>
</form>
</body>
</html>
测试面板.ASPX.VB
Public Class testpanel
Inherits System.Web.UI.Page
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
End Sub
Protected Sub BTN2_Click(sender As Object, e As EventArgs)
txt4.Text = txt3.Text
End Sub
Protected Sub btn1_Click(sender As Object, e As EventArgs)
txt2.Text = txt1.Text
End Sub
End Class