Delayed loading of TreeView in ModalPopup ?

Last post 06-06-2008 5:18 AM by kitog. 0 replies.

Sort Posts:

  • Delayed loading of TreeView in ModalPopup ?

    06-06-2008, 5:18 AM
    • Loading...
    • kitog
    • Joined on 02-14-2007, 5:35 PM
    • Posts 1

     I have a TreeView in a UserControl with a large number of nodes which I am displaying in a popup using ModalPopupExtender.  However it significantly slows down its host page on load while the TreeView is being populated.

     Here is a snippit of the code on the host page:

        <cc1:ModalPopupExtender ID="ContainerPopupExtender" runat="server" BackgroundCssClass="modalBackground"
            CancelControlID="btnContainerClose" OkControlID="btnContainerOk" PopupControlID="pnlContainer"
            TargetControlID="cAddContainerBtn" >
        </cc1:ModalPopupExtender>
         <asp:Panel ID="pnlContainer" runat="server"  Style="display: none">
            <uc2:ContainerSelection ID="ucContainerSelection" runat="server" />
            <div style="modalControls">
                <asp:Button ID="btnContainerOk" runat="server" Text="OK" Style="display: none" />
                <asp:Button ID="btnContainerClose" runat="server" Text="Close" />
            </div>    
        </asp:Panel>  

     And here is the ContainerSelection aspx: 

    <asp:Panel ID="pnlContainerUserControl" runat="server" >
    <asp:Label ID="lblTitle" runat="server" Text="Select a container"></asp:Label>
    <asp:TreeView ID="tvContainers" runat="server" OnSelectedNodeChanged="tvContainers_SelectedNodeChanged">
    </asp:TreeView>
    </asp:Panel>
     The tvContainers TreeView is populated  from  a DB  in the Page_Load() method of the user control.

    I tried to use a method described by Joshua Stengel on CodeProject which uses an asp:Timer to postpone the loading of the TreeView content by enclosing it in an UpdatePanel. It all appeared to work fine until I tried to select one of the nodes, at which point I get a JavaScript error 'ct00_DefaultContent_ucContainerSelection_tvContainers_Data' is undefined'.

     After some googling about ModalPopupExtender, UpdatePanel and TreeView's I find out that the TreeView control isn't compatible with an UpdatePanel (however I've seen some sample code where this is the case).

    Is it possible to do the above ?

    Are there any other solutions to delay the loading of a TreeView in this scenario ? 

    Some background info:

    • The number of root nodes in the TreeView is significant, so only loading a node when its expanded (e.g. using a web service) isn't going to help.
    • I'm using ASP.NET 2.0
    • The web application uses master pages. 
    • The TreeView content won't change while its displayed, so loading up the whole hierarchy on the initial load is acceptable.
    • All I need to do is select a single node.

    Any help would be appreciated.

    Kitog. 

Page 1 of 1 (1 items)
Microsoft Communities
Page view counter