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

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

  1. vikasparihar

    vikasparihar

    Joined:
    May 27, 2010
    Messages:
    1
    I am using TreeView Control in Asp.net. 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
    1. Advertising

  2. vikasparihar

    nick_c_66

    Joined:
    Jul 9, 2010
    Messages:
    1
    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:

    Code:
    <asp:UpdatePanel ID="upTreeView" runat="server">
        <ContentTemplate>
    [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>
    </ContentTemplate>[/INDENT]
    </asp:UpdatePanel> 
    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
     
    nick_c_66, Jul 9, 2010
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. TimmyC
    Replies:
    0
    Views:
    1,793
    TimmyC
    Oct 11, 2007
  2. Andy Morrison

    click click click

    Andy Morrison, Dec 18, 2007, in forum: Computer Support
    Replies:
    7
    Views:
    1,020
    Plato
    Dec 20, 2007
  3. harriet
    Replies:
    0
    Views:
    1,777
    harriet
    Sep 9, 2008
  4. Sangeeth
    Replies:
    0
    Views:
    2,266
    Sangeeth
    Jun 25, 2009
  5. Anumitha
    Replies:
    1
    Views:
    3,109
Loading...

Share This Page