我的页面上有3个updatepanel,我希望在触发事件时更新其中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>
目前此更新面板将更新将重新排序项目或复选框状态更改。 现在我有第二个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";
//lblOrderChangedNotification.DataBind();
//UpdatePanelAlertOrderNotification.Update();
}
我已经介入了代码,我无法弄清楚它为什么不起作用。
我累了的事: 我累了: 将UpdatePanelAlertOrderNotification的UpdateMode设置为always。 将UpdatePanelAlertOrderNotification的UpdateMode更改为Conditional,删除其触发器并让代码隐藏函数更新 updatepanel直接。 将文本存储在会话中以及页面发布时,以检查会话中是否有文本。我可以在pageLoad中跳过这段代码 功能,它仍然没有做任何事情。 (尝试两行注释掉,然后只有1,然后没有注释掉。)
protected void Page_Load(object sender, EventArgs e)
{
if (Session["AlertOrderChangedNotification"] != null)
{
lblOrderChangedNotification.Text = Session["AlertOrderChangedNotification"] as string;
//lblOrderChangedNotification.DataBind();
//UpdatePanelAlertOrderNotification.Update();
}
}
我不知道我是否遇到问题,因为我有两个具有相同触发器的更新面板(尽管如此 我尝试将其从UpdatePanelAlertOrderNotification中删除并将其设置为始终。)
张家: 所以我尝试添加一个新按钮并让updatepanel更新。这有效。如果我将触发器切换回重新排序列表,则它不起作用。所以我的问题是,我可以使用相同的触发器有2个不同的updatePanel吗?如果我不能通过调用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>
任何帮助都会很棒。 谢谢布拉德
答案 0 :(得分:0)
我猜你的更新面板没有得到适当的通知,我会设置带有条件触发器的包装,然后让它在其他两个上调用update方法。
您要确定的一件事是,您的代码实际上也会更新这些项目的显示。
答案 1 :(得分:0)
你遇到的问题是控件rlAlerts位于第一个更新面板的内容模板中,当你在第二个更新面板中定义异步触发器时,它不知道rlAlerts,因为它已经从第1个命名容器开始。 UpdatePanel的。
尝试以下方法之一:
在prerender上为第二个更新面板的代码隐式注册触发器:
UpdatePanelAlertOrderNotification.Triggers.Add(new AsyncPostBackTrigger() {ControlID = rlAlerts .UniqueID,EventName =“ItemReorder”});