In the past, if you wanted to use a tree control on a WEB page, it was often a little troublesome. Sometimes you even had to write your own code to display data in a tree list. In asp.net, we can easily use the Internet Exploer Web Controls control provided by Microsoft to implement a tree list. This set of Internet Exploere Web Controls provided by Microsoft includes MultiPage, TabStrip, TOOLbar, and Treeview Controls. In this article, we will look at how to use the Treeview control and XML in ASP.net to implement a tree-like list.
Microsoft's control set can be in http://asp.net/IEWebControls/Download.aspx? Download tabindex = 0 & tabid = 1, and run setup to install it. Now let's try to use the Treeview control as a simple example.
Create a new WEB project in vs.net. in the toolbox, right-click the shortcut menu and select "Add new project". In the custom toolbox, select the TREEVIEW control (note that the namespace is the Microsoft Internet Exploere web control namespace). After you press OK, you can see the Treeview control in the toolbox.
Drag the treeview control to the form and switch to the HTML view. The following code is displayed:
<% @ Register TagPrefix = "ie"
Namespace = "Microsoft. Web. UI. WebControls"
Assembly = "Microsoft. Web. UI. WebControls" %>
Of course, you can change the tag value of TagPrefix, for example, to FooBar. In the future, when you reference the Treeview control, reference it as follows:
<FooBar: TreeView runat = "server".../>
Now, you can click the nodes attribute in the properties box of the Treeview control to add nodes to the tree. This is not detailed here because it is relatively simple. The following code adds nodes:
<Form runat = "server">
<Ie: TreeView runat = "server">
<Ie: TreeNode Text = "Isaac Gibson" Expanded = "True">
<Ie: TreeNode Text = "Birth-1766"/>
<Ie: TreeNode Text = "Death-1827"/>
<Ie: TreeNode Text = "Spouse">
<Ie: TreeNode Text = "Ritty Gibson"/>