views:

1206

answers:

1

When I assign the AssociatedUpdatePanelId, the progress does not display when I select a state, but when I leave it blank, it displays the progress.

Here is the aspx markup:

<div>
    <asp:ListBox ID="lstStates" runat="server" AutoPostBack="True"
    OnSelectedIndexChanged="lstStates_SelectedIndexChanged" SelectionMode="Multiple">
    </asp:ListBox>
</div>
<div>
    <asp:UpdatePanel ID="UpdatePanel1" runat="server">
    <ContentTemplate>
    <asp:Panel ID="pnlCounty" runat="server">
    <asp:ListBox ID="lstCounties" runat="server" SelectionMode="Multiple">
    </asp:ListBox>
    </asp:Panel>
    </ContentTemplate>
    <Triggers>
    <asp:AsyncPostBackTrigger ControlID="lstStates" EventName="SelectedIndexChanged" />
    </Triggers>
    </asp:UpdatePanel>
    <asp:UpdateProgress ID="UpdateProgress2" runat="server" DisplayAfter="1"
                        AssociatedUpdatePanelID="UpdatePanel1">
    <ProgressTemplate>
    <img src="../images/loader2.gif" />
    Loading Counties...
    </ProgressTemplate>
    </asp:UpdateProgress>
</div>
+1  A: 

According to this article, external triggers for an UpdatePanel do not fire an associated UpdateProgress, since the implementation of enabling the UpdateProgress control searches the control hierarchy for the calling control; an external trigger will not be present in the control hierarchy.

The article does, however, suggest injecting some JavaScript to make up for this error; I have modified it to (hopefully) fit your needs:

<script type="text/JavaScript" language="JavaScript">
    function pageLoad()
    {      
       var manager = Sys.WebForms.PageRequestManager.getInstance();
       manager.add_endRequest(endRequest);
       manager.add_beginRequest(OnBeginRequest);
    }
    function OnBeginRequest(sender, args)
    {
      var postBackElement = args.get_postBackElement();
      if (postBackElement.id == 'lstStates')
      { 
     $get('UpdateProgress2').style.display = "block";  
      }
   }
</script>
Matthew Jones
What do you mean by external trigger? The fact that the UpdateProgress is outside of the UpdatePanel
Xaisoft
No, the fact that the ListBox is outside of the UpdatePanel and is a trigger for that panel.
Matthew Jones
Ok, I got you. Thanks.
Xaisoft