Select, navigate, and check boxes in ASP. NET-Treeview Web Server Control

Source: Internet
Author: User

The ASP. NET Treeview control allows you to easily respond when a user clicks a node, or change the behavior of a node so that the behavior is similar to that of a hyperlink. In addition, you can use the Treeview control to display check boxes next to each node so that you can select multiple nodes at a time.

 

1. Selection and navigation

Each node has a text attribute and a value attribute. The value of the text attribute is displayed in the Treeview control, and the value attribute is used to store other data about the node, such as node-related data that is passed to the send-back event.

When you click a node of the Treeview control, a selection event (by sending back) or another page may be triggered. If the navigateurl attribute is not set, clicking a node will trigger the selectednodechanged event, which can be used to provide custom functions. You can also check the selected attribute of a node to determine whether the node has been selected. If this attribute is set to true or the select method is called for the node, the node is selected programmatically.

Each node also has a selectaction attribute that can be used to specify the operations that will occur when a node is clicked, such as expanding or folding a node. To avoid the selectednodechanged event when you click a node, but go to another page, set the navigateurl attribute of the node to a value that is not a null string.

 

Ii. Check box

If you want to select multiple nodes, you can use the Treeview control to display the check box next to the node image. If you set the showcheckboxes attribute to a treenodetype that is not treenodetype. None, the check box is displayed next to the specified node. When the check box is displayed, you can use the treenodecheckchanged event to run a custom routine when the status of the check box sent to the server changes. When the next page is sent to the server, the checkednodes attribute is filled with the selected node.

The Treeview control does not expose the autopostback attribute. Therefore, to submit the check box selection, you must place a control (such as the button Web Server Control) on the page to send the information back to the server.

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.