asp.net.ph

TreeView.PopulateNodesFromClient Property

System.Web.UI.WebControls Namespace   TreeView Class


.NET Framework version 2.0

Sets or retrieves a value indicating whether node data for a TreeView control is populated on demand from the client.

Syntax


Inline <asp:treeview populatenodesfromclient = = true | false ... >
Script TreeView.PopulateNodesFromClient [ = true | false ]

Property Value

This property accepts or returns only a boolean value: true to populate tree node data on demand from the client; otherwise, false. Default value is true.

Remarks

Use the PopulateNodesFromClient property to specify whether node data for a TreeView control is populated on demand from the client.

There are cases where it is not practical to statically predefine the tree structure due to data size or custom content that depends on user input. For these cases, 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.

The method assigned to handle the event should be able to do the following:

  1. retrieve node data from a data source
  2. for each row of data in the source, create a TreeNode object
  3. bind the data into the node object
  4. set the node's properties
  5. add the node structure to the ChildNodes collection of the node being populated

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 only in Microsoft Internet Explorer version 5.5 and later and Netscape 6.0 and later.

Example

The following examples demonstrate how to use the PopulateNodesFromClient property to render client-side script that is used to expand and collapse nodes on compatible browsers.

Populating TreeView Nodes On Demand
Run Sample | View Source
Populating TreeView Nodes On Demand Using Page Titles
Run Sample | View Source
Populating TreeView Nodes from a Database
Run Sample | View Source
See Also

TreeView Members Skip Navigation Links




Home
Suggested Reading


Previous page Back to top Next page

© 2000-2010 Rey Nuñez All rights reserved.

If you have any question, comment or suggestion
about this site, please send us a note

You can help support asp.net.ph