我的页面上有3个更新面板,我希望其中2个在触发事件时更新。在其中一个更新面板中,我有一个ASP ReoderList。
<asp:UpdatePanel ID="upMain" UpdateMode="Conditional" runat="server" style="left: 0px; top: 0px; min-height: 100px; width: 495px; overflow: auto;">
<ContentTemplate>
<div class="reorderListDemo" style="position: relative; left: -41px; width: 490px; overflow: auto;">
<ajax:ReorderList ID="rlAlerts" Style="min-height: 100px; padding: 0px 6px 0px 0px;" Width="480px" runat="server" PostBackOnReorder="false" CallbackCssStyle="callbackStyle" DragHandleAlignment="Left" DataKeyField="ItemID" SortOrderField="Priority" OnItemReorder="rlAlerts_ItemReorder">
<ItemTemplate>
<%--set the class to inactiveAlert if the active flag is set to false--%>
<div id="alertItem<%# Eval("ItemID")%>" class="<%# Convert.ToBoolean(Eval("Active")) ? "" : "inactiveAlert" %>" onclick="updateAlertPreview('<%# Eval("ItemID")%>','<%# Eval("Priority")%>','<%# Eval("Title") %>','<%# Eval("Description") %>', '<%# Eval("StartDate") %>', '<%# Eval("EndDate") %>', '<%# Eval("Image") %>');">
<div style="position: relative; float: left; left: 10px; padding-top: 6px; overflow: hidden; width: 180px; height: 17px;">
<asp:Label ID="Label4" runat="server" Text='<%# HttpUtility.HtmlEncode(Convert.ToString(Eval("Title"))) %>' />
</div>
</div>
</ItemTemplate>
<ReorderTemplate>
<asp:Panel ID="Panel2" runat="server" CssClass="reorderCue" />
</ReorderTemplate>
<DragHandleTemplate>
<div class="dragHandle">
</div>
</DragHandleTemplate>
</ajax:ReorderList>
</div>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="rlAlerts" EventName="ItemReorder" />
<asp:AsyncPostBackTrigger ControlID="ckbxShowInactive" EventName="CheckedChanged" />
</Triggers>
</asp:UpdatePanel>
当前,此更新面板将更新项目或重新排序或复选框状态更改。
现在我有了第二个更新面板,它在重新排序列表时不会更新。
<asp:UpdatePanel ID="UpdatePanelAlertOrderNotification" UpdateMode="Conditional" runat="server">
<ContentTemplate>
<asp:Label ID="lblOrderChangedNotification" runat="server"></asp:Label>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="rlAlerts" EventName="ItemReorder" />
</Triggers>
</asp:UpdatePanel>
下面是我的代码:
protected void rlAlerts_ItemReorder(object sender, AjaxControlToolkit.ReorderListItemReorderEventArgs e)
{
.....
Session["AlertOrderChangedNotification"] = Resources.LocalizedText.Alert_Order_Changed;
lblOrderChangedNotification.Text = "AWESOME";
}
我已经完成了这段代码,我不明白它为什么不能工作。
我累的事情:
我累了:
将UpdatePanelAlertOrderNotification的UpdateMode设置为Always。
若要将UpdatePanelAlertOrderNotification的UpdateMode设置为Conditional,请移除其触发器并让代码隐藏函数更新
直接更新面板。
在会话中存储文本,并在页面帖子触发时检查会话中是否有文本。我可以在页面加载中跳过此代码
但它仍然不起作用。(两行都被注释掉,然后只有1行,然后没有一行被注释掉。)
protected void Page_Load(object sender, EventArgs e)
{
if (Session["AlertOrderChangedNotification"] != null)
{
lblOrderChangedNotification.Text = Session["AlertOrderChangedNotification"] as string;
}
}
我不知道我是否有问题,因为我有两个具有相同触发器的更新面板(即使
我尝试从UpdatePanelAlertOrderNotification中删除它,并将其设置为Always。)
Changs:
所以我尝试添加一个新按钮并让更新面板更新。这是可行的。如果我将触发器切换回重新排序列表,它将不起作用。所以我的问题是,我可以有两个不同的updatepanels具有相同的触发器吗?如果我不能,我应该可以通过调用updatePanelAlertOrderNotification.update()来进行中断的一次更新?想法?
<div style="position: absolute; top: 195px; right: 10px; height: 100px; width: 120px; overflow: hidden;">
<asp:UpdatePanel ID="UpdatePanelAlertOrderNotification" UpdateMode="Conditional" runat="server">
<ContentTemplate>
<asp:Label ID="lblOrderChangedNotification" runat="server"></asp:Label>
</ContentTemplate>
<Triggers>
<%--<asp:AsyncPostBackTrigger ControlID="rlAlerts" EventName="ItemReorder" />--%>
<asp:AsyncPostBackTrigger ControlID="btnUpdateBrokenUpdatePanel" EventName="Click" />
</Triggers>
</asp:UpdatePanel>
<div style="position: relative; top: 25px; left: 10px;">
<asp:Button ID="btnUpdateBrokenUpdatePanel" runat="server" CssClass="redButton" Width="300px" Height="25px" Text="Update Broken UPdatePanel" OnClick="btnUpdateBrokenUpdatePanel_Click" />
</div>
任何帮助都是了不起的。
谢谢Brad