Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3615250
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T22:21:00+00:00 2026-05-18T22:21:00+00:00

I have a Treeview with populateOnDemand set to true. I want this treeview to

  • 0

I have a Treeview with “populateOnDemand” set to true. I want this treeview to keep its state (nodes expanded/collapsed) from one page to another. Viewstate doesn’t work because the treeview is different for each page. Here is my code at the moment.

ASPX page :

<asp:TreeView
          ID="arbre"
          EnableViewState="true"
          PopulateNodesFromClient="true"
          runat="server" />

Code behind :

Protected Sub arbre_TreeNodeCollapsed(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.TreeNodeEventArgs) Handles arbre.TreeNodeCollapsed
    CType(Session("listeNoeudsOuverts"), Hashtable)(e.Node.Value) = True
End Sub

Protected Sub arbre_TreeNodeExpanded(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.TreeNodeEventArgs) Handles arbre.TreeNodeExpanded
    CType(Session("listeNoeudsOuverts"), Hashtable)(e.Node.Value) = False
End Sub


Protected Sub arbre_TreeNodePopulate(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.TreeNodeEventArgs) Handles arbre.TreeNodePopulate
    // code to populate nodes
    CType(Session("listeNoeudsOuverts"), Hashtable)(e.Node.Value) = True
End Sub

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
    If Session("listeNoeudsOuverts") Is Nothing Then
        Session("listeNoeudsOuverts") = New Hashtable()
    End If
    // other stuff
End Sub

This works well, buf I wish I could avoid the postback everytime the user expands or collapses a node. I know I can set EnebleClientScript to true and manage the events client side in Javascript but I won’t be able to use my session variable anymore. Is there a way to achieve this ?

Thank you

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-18T22:21:01+00:00Added an answer on May 18, 2026 at 10:21 pm

    I will answer myself to a certain extent.

    I’ve done some tests and research, EnableClientScript is true by default, and indeed means that expand and collapse actions are processed client side, by Javascript code that is automaticalt generated by the .Net framework. You can’t edit it.

    Apparently, if you need to add custom actions when a user expands or collapses anode, you have to use TreeNodeExpanded and TreeNodeCollapsed events, like i did above, and can’t avoid postbacks because they are triggered server-side.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a treeview with nodes like this: Foo (1234), and want to allow
I have TreeView control and I want to bind tree nodes' IsExpanded property to
I have treeview control with one level of parent and child nodes, each node
I have a TreeView <asp:TreeView ID=tvCategories runat=server ShowLines=false ShowExpandCollapse=true ExpandDepth=0 /> by default the
I have a TreeView that launches a new window when each of its TreeViewItems
I have a treeView , and i want to know if some node can
I've got a fairly simple treeview where the nodes are PopulateOnDemand and some of
I have treeview and a context menu that is shown for every node. One
I have a TreeView showing an object's properties. One of the properties is a
I have a treeview with multiple nodes with the same text and quite nested

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.