treeview with expand, collapse and change action (VB.net)
<%@ Page Language=VB Debug=true %>
<%@ Import Namespace="Microsoft.Web.UI.WebControls" %>
<%@ Register TagPrefix="IEControls"
Namespace="Microsoft.Web.UI.WebControls"
Assembly ="Microsoft.Web.UI.WebControls"
%>
<script runat=server>
Sub TreeChange(ByVal Sender as Object, _
ByVal E as TreeViewSelectEventArgs)
lblMessage.Text = "You selected node " & E.NewNode.ToString() _
& " and moved from node " & E.OldNode.ToString() & "."
End Sub
Sub TreeExpand(ByVal Sender as Object, _
ByVal E as TreeViewClickEventArgs)
lblMessage2.Text = "You expanded node " _
& E.Node.ToString() & "."
End Sub
Sub TreeCollapse(ByVal Sender as Object, _
ByVal E as TreeViewClickEventArgs)
lblMessage2.Text = "You collapsed node " _
& E.Node.ToString() & "."
End Sub
</SCRIPT>
<HTML>
<HEAD>
<TITLE>TreeView 3 Control Sample Page</TITLE>
</HEAD>
<BODY>
<form runat="server">
<Font Face="Tahoma">
<asp:Label
id="lblMessage"
runat="server"
/>
<BR>
<asp:Label
id="lblMessage2"
runat="server"
/>
<BR><BR>
<IEControls:treeview
id="MyTree3"
onSelectedIndexChanged="TreeChange"
onexpand="TreeExpand"
oncollapse="TreeCollapse"
AutoPostBack="True"
BackColor="LightYellow"
BorderStyle=9
BorderWidth=3
BorderColor="DarkBlue"
runat="server">
<IEControls:treenode Text="A">
<IEControls:treenode Text="A1"/>
<IEControls:treenode Text="A2"/>
<IEControls:treenode Text="A3">
<IEControls:treenode Text="A31"/>
<IEControls:treenode Text="A32"/>
<IEControls:treenode Text="A33"/>
</IEControls:treenode>
</IEControls:treenode>
<IEControls:treenode Text="B">
<IEControls:treenode Text="B1"/>
<IEControls:treenode Text="B2"/>
<IEControls:treenode Text="B3"/>
<IEControls:treenode Text="B4"/>
</IEControls:treenode>
</IEControls:treeview>
</Font>
</Form>
</BODY>
</HTML>
Related examples in the same category