TreeView control postback on click of plus sign when rendered using RenderControl

Discussion in 'Software' started by vikasparihar, May 27, 2010.

  1. vikasparihar


    May 27, 2010
    Likes Received:
    I am using TreeView Control in I have placed this control inside a panel. The tree control is completely binded (we don’t want populate on demand) with an Xmldatasource during a callback and then I call Panel.renderControl to return the response (HTML) to the client side callback handler.

    Problem: 1. The tree expand/collapse (on click of plus sign) is causing postback whereas when I normally bind a tree with xml during postback and without using renderControl of container control, the expand/collapse (on click of plus sign) is being handled at client side.

    I want to stop this postback and allow tree node to call javascript to toggle nodes as it does when tree is binded and renderd in case of normal page life cycle.(when render control function is not used) .Please guide.
    vikasparihar, May 27, 2010
    1. Advertisements

  2. vikasparihar


    Jul 9, 2010
    Likes Received:
    I used a TreeView control recently in a project and ran into the same issue.

    I, however, wanted to use populate on demand and only have the root node expanded. Therefore, whenever you click on the plus sign to expand a node, it would postback.

    I'm assuming when you say "panel" you mean <asp : panel> ??

    Either way, my solution was to wrap the TreeView into an updatepanel, something similar to:

    <asp:UpdatePanel ID="upTreeView" runat="server">
    [INDENT]<asp:TreeView ID="tvTree" SelectedNodeStyle-BackColor="#feffc7" SelectedNodeStyle-BorderStyle="Dotted" 
                    SelectedNodeStyle-BorderColor="#C0C0C0" SelectedNodeStyle-BorderWidth="1px" PopulateNodesFromClient="true" 
                    EnableClientScript="False" ShowExpandCollapse="true" ShowLines="false" 
                    NoExpandImageUrl="~/images/tree/dash.gif" runat="server"></asp:TreeView>
    Using this approach, now when the expand/collapse is clicked / or a node itself is click, the page will post asynchronously.

    I hope this is what you were looking for, sorry for a late response, but i thought I'd share my experience.

    nick_c_66, Jul 9, 2010
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.