views:

54

answers:

2

I have 3 updatepanels on my page and I want 2 of them to update when an event is fired. In one of the update panels I have an 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>

Currently this update panel will update will either the items are reordered or the checkbox state changes. Now I have this second updatePanel that isn't updating when the list is reordered.

<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>

Here is my code behind:

    protected void rlAlerts_ItemReorder(object sender, AjaxControlToolkit.ReorderListItemReorderEventArgs e)
        {
           .....
           Session["AlertOrderChangedNotification"] = Resources.LocalizedText.Alert_Order_Changed;

            lblOrderChangedNotification.Text = "AWESOME";
            //lblOrderChangedNotification.DataBind();
            //UpdatePanelAlertOrderNotification.Update();
}

I've stepped through the code and I can't figure out why it isn't working.

Things I have tired: I have tired : to set UpdatePanelAlertOrderNotification's UpdateMode to always. to have UpdatePanelAlertOrderNotification's UpdateMode to Conditional, remove its triggers and have the code behind function update the updatepanel directly. to store the text in the session and when the page post fires to check if there is text in the session. I am able to step over this code in the pageLoad function and it still doesn't do anything. (Tried with both lines commented out and then with only 1, then with none of them commented out.)

protected void Page_Load(object sender, EventArgs e)
        {
            if (Session["AlertOrderChangedNotification"] != null)
            {
                lblOrderChangedNotification.Text = Session["AlertOrderChangedNotification"] as string;
                //lblOrderChangedNotification.DataBind();
                //UpdatePanelAlertOrderNotification.Update();
            }
        }

I don't know if I'm having an issue because I have two update panels that have the same trigger (Even though I tried removing it from UpdatePanelAlertOrderNotification and have it set to always.)

Changs: So I tried to add a new button and get the updatepanel to update. This works. If I switch the triggers back to the reorder list it doesn't work. So My question is, Can I have 2 different updatePanels with the same trigger? IF I can't I should be able to have the broken one update by calling UpdatePanelAlertOrderNotification.Update()?? Ideas?

<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>

Any help would be awesome. Thanks Brad

A: 

I'm guessing that you are having an issue with the update panels not getting proper notice, I would setup the wrapping one with a conditional trigger, and then have it call the update method on both of the other ones.

One thing you want to make sure of is that your code that actually updates the display of those items is executed as well.

Mitchel Sellers
I would agree that the UpdatePanelAlertOrderNotification isn't updating/ receiving the proper notice. I don't know why it isn't. I'm confused - "I would setup the wrapping one with a conditional trigger," you mean add <trigger> <asp:AsyncPostBackTrigger ControlID="rlAlerts" EventName="ItemReorder" /> </> to UpdatePanelAlertOrderNotification ?
Brad8118
A: 

The problem that you have is that the control rlAlerts is in the content template of the first update panel and when you define the asynchronous trigger in the 2nd updatepanel, it doesnt know about rlAlerts because it has been prepended with naming container from 1st updatepanel.

Try one of these approaches:

  • Take rlAlerts outside of the updatepanel, if that is possible
  • In the code behind for ItemReorder event handler to explicitly call UpdatePanelAlertOrderNotification.Update(). SOund like you have tried and it doesnt work, which is strange
  • Explicitly register the trigger from code behind for the 2nd updatepanel on prerender:

    UpdatePanelAlertOrderNotification.Triggers.Add(new AsyncPostBackTrigger() {ControlID = rlAlerts .UniqueID, EventName = "ItemReorder"});

Fadrian Sudaman
1 - I can't move rlAlerts.2 - Not sure what not working3 - Tried this. Good Idea but no luck. I then also tried to put an invalid ControlID in and the page throws an error saying that it can't find the control. So it must be finding.
Brad8118
That is very odd. I suppose it will take sometime to resolve it and will be hard to help without actually in the environment and debugging it. If you are desperate, here is my suggestion for workaround. Add a hidden button to the 2nd update panel say btnHidden and wire it up with a dummy method. Then in the ItemReorder method you will do ScriptManager.RegisterStartupScript(..........., "__doPostback('" + btnHidden.UniqueID + "', '')", true); Not sure if you should use UniqueID or ClientID, but one of them should work. This basically force another postback through to the 2nd update panel
Fadrian Sudaman
Ya thats a good Idea. Its a hack but it should work. I'll let you know.
Brad8118