Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/288.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/asp.net/31.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# Can';t更新第二个更新面板_C#_Asp.net_Updatepanel - Fatal编程技术网

C# Can';t更新第二个更新面板

C# Can';t更新第二个更新面板,c#,asp.net,updatepanel,C#,Asp.net,Updatepanel,我的页面上有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;"> <ContentTem

我的页面上有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>
我已经完成了代码,但我不明白为什么它不起作用

我已经厌倦的事情: 我累了: 将UpdatePanelAlertOrderNotification的UpdateMode设置为always。 要使UpdatePanelAlertOrderNotification的UpdateMode具有条件,请删除其触发器并让代码隐藏函数更新 直接更新面板。 在会话中存储文本,并在页面post触发时检查会话中是否有文本。我可以在pageLoad中跳过此代码 函数,但它仍然不做任何事情。(尝试将两行都注释掉,然后仅使用1,然后没有一行注释掉。)

我不知道我是否有问题,因为我有两个具有相同触发器的更新面板(即使 我尝试将其从UpdatePanelAlertOrderNotification中删除,并将其设置为“始终”。)

张: 因此,我尝试添加一个新按钮并更新updatepanel。这很有效。如果我将触发器切换回重新排序列表,它将不起作用。所以我的问题是,我可以有两个不同的UpdatePanel使用相同的触发器吗?如果不能,我应该能够通过调用UpdatePanelerTorderNotification.update()来更新损坏的一个??想法


任何帮助都会很棒。
感谢Brad

我猜您遇到了更新面板未得到适当通知的问题,我会使用条件触发器设置包装面板,然后让它在其他两个面板上调用更新方法


您需要确保的一点是,实际更新这些项目显示的代码也会执行。

您遇到的问题是,控件rlAlerts位于第一个更新面板的内容模板中,当您在第二个更新面板中定义异步触发器时,它不知道rlAlerts,因为它已经在第一个updatepanel中添加了命名容器

尝试以下方法之一:

  • 如果可能的话,将rlAlerts置于updatepanel之外
  • 在ItemReorder事件处理程序的代码隐藏中,显式调用UpdatePanelAlertOrderNotification.Update()。听起来你已经试过了,但没用,这很奇怪
  • 在prerender上为第二个updatepanel显式注册来自代码隐藏的触发器:

    UpdatePanelAlertOrderNotification.Triggers.Add(新的AsyncPostBackTrigger() {ControlID=rlAlerts.UniqueID,EventName=“ItemReorder”})


可能与此有关?UpdateMode=“Conditional”为什么不将其设置为always?我确实将其设置为always,但它仍然没有更新。我同意UpdatePanellerTorderNotification没有更新/接收正确的通知。我不知道为什么不是。我很困惑——“我会用条件触发器设置包装”,你的意思是添加到UpdatePanelAlertOrderNotification?1-我不能移动警报。2-不确定什么不起作用3-尝试了这个。好主意,但运气不好。然后,我还尝试在中放入一个无效的ControlID,页面抛出一个错误,表示找不到该控件。所以它一定是在寻找,这很奇怪。我想解决这个问题需要一些时间,如果不在环境中进行实际调试,将很难提供帮助。如果你感到绝望,这里是我的建议解决办法。在第二个更新面板中添加一个隐藏按钮,比如btnHidden,并使用一个虚拟方法将其连接起来。然后,在ItemReorder方法中,您将执行ScriptManager.RegisterStartupScript(……..,“\uu doPostback(“+btnhiden.UniqueID+”,“”),true);不确定您是否应该使用UniqueID或ClientID,但其中一个应该有效。这基本上迫使第二个更新面板再次发回。这是个好主意。这是一个黑客,但它应该工作。我会让你知道的。
<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();
}
protected void Page_Load(object sender, EventArgs e)
        {
            if (Session["AlertOrderChangedNotification"] != null)
            {
                lblOrderChangedNotification.Text = Session["AlertOrderChangedNotification"] as string;
                //lblOrderChangedNotification.DataBind();
                //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>