TreeView::PopulateNodesFromClient Property
Gets or sets a value indicating whether node data is populated on demand from the client.
Assembly: System.Web (in System.Web.dll)
Sometimes, it is not practical to statically predefine the tree structure due to data size or custom content that depends on user input. Because of this, the TreeView control supports dynamic node population. When the PopulateOnDemand property for a node is set to true, that node gets populated at run time when the node is expanded.
In addition to populating nodes on demand, it is possible to populate the nodes directly on a supported client browser. When the PopulateNodesFromClient property is set to true, a service is called from the client to populate the tree nodes, which eliminates the need to post back to the server. Otherwise, the TreeView control posts back to the server to populate the nodes.
Note: |
|---|
The EnableClientScript property must also be set to true in order for the PopulateNodesFromClient property to be set to true. |
To populate a node on the client, first set the PopulateNodesFromClient property to true and then set the PopulateOnDemand property for the node to true. Next, define an event-handling method for the TreeNodePopulate event that programmatically populates the node. A typical event-handling method retrieves node data from a data source, places the data into a node structure, and then adds the node structure to the ChildNodes collection of the node being populated. You create a node structure by adding TreeNode objects to the ChildNodes collection of a parent node.
Note: |
|---|
When the PopulateOnDemand property for a node is set to true, the node must be populated dynamically. You cannot declaratively nest another node below it; otherwise, an error will occur on the page. |
Note: |
|---|
The client-side node population feature is supported in browsers that support callback scripts. To check whether a browser supports callback scripts access, use the SupportsCallback property of the HttpBrowserCapabilities class. You can access the instance of the HttpBrowserCapabilities class for the current request through the Browser property of the HttpRequest class. |
The value of this property is stored in view state.
The following code example demonstrates how to use the PopulateNodesFromClient property to enable client-side population of the nodes in the TreeView control. Notice that when client-side node population is enabled, nodes are populated dynamically on the client, without the need to post back to the server.
Windows 7, Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98
The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.
Note: