<asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<div>
<asp:DropDownList runat="server" EnableViewState="true" DataTextField="Name" DataValueField="Id" DataSourceID="ListSource" ID="List" OnDataBound="List_OnDataBound" AutoPostBack="True" OnSelectedIndexChanged="List_SelectedIndexChanged">
</asp:DropDownList>
</div>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="List2" EventName="SelectedIndexChanged" />
<asp:AsyncPostBackTrigger ControlID="List" EventName="SelectedIndexChanged" />
</Triggers>
</asp:UpdatePanel>
on List_SelectedIndexChanged我正在启用/禁用不在更新面板中的链接按钮,但它不起作用。我不想在更新面板上放置linkbutton因为点击它我想要整页回发。
答案 0 :(得分:0)
这是您的解决方案:How to update controls which are outside of updatepanel during partial page rendering?
解决方案是使用ScriptManager.RegisterDataItem()
。
<asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode=Conditional>
<ContentTemplate>
<asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
<asp:Button ID="Button1" runat="server" Text="Update Button" onclick="Button1_Click" />
</ContentTemplate> </asp:UpdatePanel>
<asp:Label ID="Label2" runat="server" Text="Label"></asp:Label>
protected void Button1_Click(object sender, EventArgs e)
{
//Updating Label1 Text with the current Time Ticks
Label1.Text = DateTime.Now.Ticks.ToString();
//Register Label2 control with current DataTime as DataItem
ScriptManager1.RegisterDataItem(Label2, DateTime.Now.ToString());
}