ASP.NET really useful features are their expansion. Developers around the world can create their own custom controls, which can be easily defined in your own process. Among them, Internet Explorer Web Controls is a collection of Microsoft created outside the standard ASP.NET control.
The drive and the file and folder under the Windows Explorer are arranged in accordance with a hierarchy, and there is a TreeView control in this control to provide us with a hierarchical display information. The TreeView control contains a list of some entries called "Node". Each node can have its own node collection, providing a deeper-deepest data definition. Each node can be folded, allowing the visitor to look up in a TreeView control, only the data he is interested in. Just like the Windows resource manager.
This article will show you the work you need to do on the ASP.NET page.
The TreeView control demonstration first is clear that the environment is the environment. As long as the environment is correct, the next job is very easy: to test the control, you have a file called IE WebControls, the specific file can click here to download or go to Microsoft The website download: The download address is installed according to the method he provides. If you are unclear, please see your ReadMe documentation carefully. Here you skip the download method, directly enter the environment configuration: IE Web Controls1, double-click the installation, default: System disk: / program files / ie web controls directory. 2. Run "Program - Microsoft Visual Studio.Net 2003 - Visual Studio.net Tool - Microsoft Visual Studio.net 2003 Command Prompt", go to the IE Web Control installation directory. 3. Run Build.bat. 4. Run XCOPY / S / I ./build/runtime (Website Root Catalog, Default Dish): / INETPUB / WWWROOT / WebCtrl_client / 1_0 / y. In the Toolbox --Web Form, select Add / Transfer ... ", select the .NET FRAMWORK component in the pop-up dialog box, click Browse, find the IE WebControl.dll file, Add it. This is configured to configure the operating environment. Next, the actual exercise phase is made.
First, define the TreeView control
Code copy box 'import namespace
<% @ Import namespace = "Microsoft.Web.ui.WebContros"%>
'Register this namespace and give it a TagPrefix to facilitate the definition of controls in this control library
<% @ register tagprefix = "IEControls"
Namespace = "Microsoft.Web.ui.WebControls"
askEMBLY = "Microsoft.Web.ui.WebControls"
%>
'After setting up the instruction, you can define a TreeView control below.
ID = "tvbasic" AutoSelect = "false" Shoplus = "True" Showlines = "true" ExpandLevel = 2 Runat = "server" > ------------ IDControls: TreeView> Let's explain the corresponding code: AutoSelect = "false" When the visitor is positioned in the TreeView control, the arrow on the keyboard can be used to perform this positioning. When this TreeView control is set to True, when this TREEVIEW control is set to true, You can use the keys on the keyboard to scroll in the TreeView control. If you choose to be a entry. If you set it to false, you don't allow this. Shouwlus = "true" When you receive two nodes in a TreeView control You can display a plus sign ( ), visitors know that this node can be expanded. By setting the showplus property, you can control if the plus is displayed in this location. If this property value is set to true; otherwise not Using .Showlines = "true" between two nodes in a TreeView control, you can display some lines, by setting the showlines property, you can control whether this line is displayed .Expandlevel = 2 This TreeView control ExpandLEVEL property is used to determine In the default, the number of levels is expanded along the hierarchy of this TreeView control. If you create a TreeView control, you need to add some TREENODE controls to display some information. TREENODE control is displayed as an item in the hierarchy of the TreeView control .treenode control can contain TreeView controls; or, the control itself can also Independent existence. The following will show you how to define TREENODE controls in a TreeView control. This instance will show some websites I like, each of which can be an independent, or there are other websites. This TreeView control It has the following definition: Code Copy Box ID = "TVWebsite" AutoSelect = "false" ShowPlus = "true" Showlines = "true" ExpandLevel = 2 Runat = "server" > 'Next, in the start and end tag of the TreeView control, define the TREENODE control iecontrols: Treenode> iecontrols: Treenode> iecontrols: Treenode> Iecontrols: Treenode> [Ctrl A All Choose to copy] Among them, a two-stage node is defined. This tree view contains the two large nodes of "Design Class Site" and "Programming Site", and two sub-nodes "ASP program" in the "Program Site" And "ASP.NET Programming", where each child node has defined other nodes. Pay attention to the difference between TREENODE controls and separate TREENODE controls that contain other nodes. When there is other TREENODE control in a TREENODE control, These sub-controls define between the start and end tags of their parent controls: "I often go" is the current node item. Visitors can hit the carriage return, or click the mouse on this node. Then, the visitor can use the arrow on the keyboard to carry along the hierarchy of the tree view. Location. Third, use the TREENODE control as a link in the TreeView control In the above tutorial, "I often go often" can't jump to the corresponding site under the click of the mouse, so that the TreeView control seems to lose its value. In fact, another application method of Treenode is used as a link. When the visitor selects a TREENODE control, it will be oriented to a site associated with this node. This application is useful when you need to direct visitors to a location from a page like a site map. Not much to say, let's go! Code Copy Box ID = "MyWebsite" AutoSelect = "false" ShowPlus = "true" Showlines = "true" ExpandLevel = 2 Runat = "server" > Target = "_ blank" NavigateURL = "http://www.blueidea.com/" /> Target = "_ blank" NavigateURL = "http://www.windstudio.net/" /> NavigateURL = "http://www.blueidea.com/" /> iecontrols: Treenode> Target = "_ blank" NavigateURL = "http://www.aspcool.com/" /> Target = "_ blank" NavigateURL = "http://www.aspx.cn/" /> Target = "_ blank" NavigateURL = "http://www.asp.net/" /> iecontrols: Treenode> Target = "_ blank" NavigateURL = "http://www.9cbs.net/" /> iecontrols: Treenode> Iecontrols: TreeView> [Ctrl A All Choose and Copy] Where the TREENODE structure is different from the previous, you can set the text displayed on this link by setting the Text property. The NaviGateURL property is set to the visitor to be redirected to the target site location. At the same time, you can also use the target attribute to specify whether you are elected to display the specified link in a new window. The above described is just the most basic function of the TreeView control, is intended to make you. NET enthusiasts know the TreeView control, we can also use images in the TREENODE control, you can also use the style in the TreeView control, you can write code that triggered when a TREENODE control is selected in the TreeView control! If you have this sense Interest, want to communicate with me to go to my homepage: http://www.lemongtree.net/ Post your opinion! The controls involved in this article can also be downloaded from the small station for free download! In the next article, how to use how to implement navigation. After writing the TreeView control, some netizens have filed if the small station message will be made to write the specified code when selecting a TREENODE control, and today I write this tutorial. Writing a code that triggered when a TREENODE control is selected in the TreeView control, when you add a TreeView control in your ASP.NET page, you may want to write some code when you select a node in this TreeView control Time, trigger the code. The TreeView control provides an event that you can write the corresponding event processing code for it. This event provides you with the possibility of related processing to the selected node and the node where the visitor is located before selecting this node. This ASP.NET page will display a list of departments through a TreeView control to hierarchically. When the visitor selects a node, he will see the ID of the selected node, and the ID of the node on the selected node, which is exposed to the visitor. Note that the autopostback property is set to TRUE. This means that when there is a Treenode control being selected, this page will be submitted to the server for processing. The process triggered when a node is selected, and the process triggered is specified by an onselectedIndexChange property. In the TreeView control, you define a TREENODW control in this way: