C# ASP.NET更新面板仅更新一次
嗨,我有一个这样的更新面板C# ASP.NET更新面板仅更新一次,c#,asp.net,updatepanel,partial-postback,C#,Asp.net,Updatepanel,Partial Postback,嗨,我有一个这样的更新面板 <asp:UpdatePanel ID="Updatepanel1" runat="server"> <Triggers> <asp:AsyncPostBackTrigger ControlID="RadioButtons1" EventName="SelectedIndexChanged" /> <asp:AsyncPostBackTrigger ControlID="DropDown
<asp:UpdatePanel ID="Updatepanel1" runat="server">
<Triggers>
<asp:AsyncPostBackTrigger ControlID="RadioButtons1" EventName="SelectedIndexChanged" />
<asp:AsyncPostBackTrigger ControlID="DropDown1" EventName="SelectedIndexChanged" />
<asp:AsyncPostBackTrigger ControlID="DropDown2" EventName="SelectedIndexChanged" />
<asp:AsyncPostBackTrigger ControlID="DropDown3" EventName="SelectedIndexChanged" />
</Triggers>
<ContentTemplate>
<asp:Label runat="server" Text="LabelToUpdate"></asp:Label>
</ContentTemplate>
</asp:UpdatePanel>
我想在每次发生上述触发器时更新标签
我第一次触发它时,一切正常。但在此之后,即使我更改了任何内容,也不会有更多的更新(就像第一次部分回发后所有控件的AutoPostBack
get设置为false,所以当我第二次更改选择时不会发生任何事情)
非常感谢您的帮助
谢谢复制并粘贴此。。工作正常:)
您所说的“所有触发器自动回发设置为false”是什么意思?您好,很抱歉造成这种混乱。我的意思是没有任何东西会在页面上发回。当我更改下拉列表和单选按钮的值时,不会发生任何事情。就好像他们不再做回发了你在回发上对这些控件进行数据绑定吗?如果(!Page.IsPostBack)-检查,则应将其嵌入到中。这些控件是动态创建的吗?您知道每次回发时控件id必须相同才能触发事件吗?您是否调试过页面加载是否得到处理?您在页面上看到任何javascript错误吗?1-回发时的数据绑定:no 2-将其嵌入if(!page.IsPostBack):我使用此检查设置默认值。我不明白你的意思。3-这些控件是动态创建的吗?:不是。但我正在回发上创建其他控件。(我在更新面板中创建其他标签)4-每次回发时控件id必须相同:它是相同的,我不会更改触发更新面板的控件的任何内容。是否处理5页的加载?它没有被处理。当我更改选择6时,没有发生任何事情-您在第页上看到任何javascript错误吗:不-我没有使用任何JavaScript6-也许您应该发布实际的代码
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<asp:RadioButtonList ID="RadioButtons1" runat="server" AutoPostBack="true">
<asp:ListItem Text="1" Selected="True"></asp:ListItem>
<asp:ListItem Text="2"></asp:ListItem>
<asp:ListItem Text="3"></asp:ListItem>
<asp:ListItem Text="4"></asp:ListItem>
</asp:RadioButtonList>
<br />
<asp:DropDownList ID="DropDown1" runat="server" AutoPostBack="true">
<asp:ListItem Text="1" Selected="True"></asp:ListItem>
<asp:ListItem Text="2"></asp:ListItem>
<asp:ListItem Text="3"></asp:ListItem>
<asp:ListItem Text="4"></asp:ListItem>
</asp:DropDownList>
<br />
<br />
<asp:DropDownList ID="DropDown2" runat="server" AutoPostBack="true">
<asp:ListItem Text="1" Selected="True"></asp:ListItem>
<asp:ListItem Text="2"></asp:ListItem>
<asp:ListItem Text="3"></asp:ListItem>
<asp:ListItem Text="4"></asp:ListItem>
</asp:DropDownList>
<br />
<br />
<asp:DropDownList ID="DropDown3" runat="server" AutoPostBack="true">
<asp:ListItem Text="1" Selected="True"></asp:ListItem>
<asp:ListItem Text="2"></asp:ListItem>
<asp:ListItem Text="3"></asp:ListItem>
<asp:ListItem Text="4"></asp:ListItem>
</asp:DropDownList>
<br />
<br />
<asp:UpdatePanel ID="Updatepanel1" runat="server">
<Triggers>
<asp:AsyncPostBackTrigger ControlID="RadioButtons1" />
<asp:AsyncPostBackTrigger ControlID="DropDown1" />
<asp:AsyncPostBackTrigger ControlID="DropDown2" />
<asp:AsyncPostBackTrigger ControlID="DropDown3" />
</Triggers>
<ContentTemplate>
<asp:Label ID="Label1" runat="server" Text="LabelToUpdate"><%= "rad: " + RadioButtons1.SelectedItem.Text + "<br />" + "drop1: " + DropDown1.SelectedItem.Text + "<br />" + "drop2: " + DropDown2.SelectedItem.Text + "<br />" + "drop3: " + DropDown3.SelectedItem.Text %></asp:Label>
</ContentTemplate>
</asp:UpdatePanel>