1.TreeView和DropDownList在一个页面
后台.vb代码
2.TreeView和DropDownList不在一个页面,分别在2个框架中
框架页
左框架页中 有个TreeView
右框架
1
<%
@ Page Language="vb" AutoEventWireup="false" Codebehind="treeDrp.aspx.vb" Inherits="Ex.treeDrp"
%>
2 <% @ Register TagPrefix="iewc" Namespace="Microsoft.Web.UI.WebControls" Assembly="Microsoft.Web.UI.WebControls, Version=1.0.2.226, Culture=neutral, PublicKeyToken=31bf3856ad364e35" %>
3 <! DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
4 < HTML >
5 < HEAD >
6 < title > treeDrp </ title >
7 < meta name ="GENERATOR" content ="Microsoft Visual Studio .NET 7.1" >
8 < meta name ="CODE_LANGUAGE" content ="Visual Basic .NET 7.1" >
9 < meta name ="vs_defaultClientScript" content ="JavaScript" >
10 < meta name ="vs_targetSchema" content ="http://schemas.microsoft.com/intellisense/ie5" >
11 < script language ="javascript" >
12 function setV()
13 {
14 document.all("v").value=TreeView1.getTreeNode(TreeView1.clickedNodeIndex).getAttribute("Text");
15 document.Form1.submit();
16 }
17 </ script >
18 </ HEAD >
19 < body MS_POSITIONING ="GridLayout" >
20 < form id ="Form1" method ="post" runat ="server" >
21 < input type ="hidden" id ="v" runat ="server" > < FONT face ="宋体" >
22 < iewc:TreeView id ="TreeView1" style ="Z-INDEX: 101; LEFT: 16px; POSITION: absolute; TOP: 72px" runat ="server" >
23 < iewc:TreeNode Text ="Node0" ></ iewc:TreeNode >
24 < iewc:TreeNode Text ="Node1" ></ iewc:TreeNode >
25 < iewc:TreeNode Text ="Node2" ></ iewc:TreeNode >
26 < iewc:TreeNode Text ="Node3" ></ iewc:TreeNode >
27 </ iewc:TreeView >
28 < asp:DropDownList id ="ddl" style ="Z-INDEX: 102; LEFT: 168px; POSITION: absolute; TOP: 72px" runat ="server" ></ asp:DropDownList ></ FONT >
29 </ form >
30 </ body >
31 </ HTML >
2 <% @ Register TagPrefix="iewc" Namespace="Microsoft.Web.UI.WebControls" Assembly="Microsoft.Web.UI.WebControls, Version=1.0.2.226, Culture=neutral, PublicKeyToken=31bf3856ad364e35" %>
3 <! DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
4 < HTML >
5 < HEAD >
6 < title > treeDrp </ title >
7 < meta name ="GENERATOR" content ="Microsoft Visual Studio .NET 7.1" >
8 < meta name ="CODE_LANGUAGE" content ="Visual Basic .NET 7.1" >
9 < meta name ="vs_defaultClientScript" content ="JavaScript" >
10 < meta name ="vs_targetSchema" content ="http://schemas.microsoft.com/intellisense/ie5" >
11 < script language ="javascript" >
12 function setV()
13 {
14 document.all("v").value=TreeView1.getTreeNode(TreeView1.clickedNodeIndex).getAttribute("Text");
15 document.Form1.submit();
16 }
17 </ script >
18 </ HEAD >
19 < body MS_POSITIONING ="GridLayout" >
20 < form id ="Form1" method ="post" runat ="server" >
21 < input type ="hidden" id ="v" runat ="server" > < FONT face ="宋体" >
22 < iewc:TreeView id ="TreeView1" style ="Z-INDEX: 101; LEFT: 16px; POSITION: absolute; TOP: 72px" runat ="server" >
23 < iewc:TreeNode Text ="Node0" ></ iewc:TreeNode >
24 < iewc:TreeNode Text ="Node1" ></ iewc:TreeNode >
25 < iewc:TreeNode Text ="Node2" ></ iewc:TreeNode >
26 < iewc:TreeNode Text ="Node3" ></ iewc:TreeNode >
27 </ iewc:TreeView >
28 < asp:DropDownList id ="ddl" style ="Z-INDEX: 102; LEFT: 168px; POSITION: absolute; TOP: 72px" runat ="server" ></ asp:DropDownList ></ FONT >
29 </ form >
30 </ body >
31 </ HTML >
后台.vb代码
1
Private
Sub Page_Load()
Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
2 TreeView1.Attributes.Add("onclick", "setV();")
3 ' If Not IsPostBack Then
4 bind()
5 Dim index As Int16 = v.Value.Trim().Substring(4)
6 TreeView1.SelectedNodeIndex = index
7 'End If
8 End Sub
9 Sub bind() Sub bind()
10 ddl.Items.Clear()
11 Dim i As Int16
12 For i = 0 To 5
13 Dim li As New ListItem(v.Value.Trim() + CStr(i), i)
14 ddl.Items.Add(li)
15 Next
16 End Sub
2 TreeView1.Attributes.Add("onclick", "setV();")
3 ' If Not IsPostBack Then
4 bind()
5 Dim index As Int16 = v.Value.Trim().Substring(4)
6 TreeView1.SelectedNodeIndex = index
7 'End If
8 End Sub
9 Sub bind() Sub bind()
10 ddl.Items.Clear()
11 Dim i As Int16
12 For i = 0 To 5
13 Dim li As New ListItem(v.Value.Trim() + CStr(i), i)
14 ddl.Items.Add(li)
15 Next
16 End Sub
2.TreeView和DropDownList不在一个页面,分别在2个框架中
框架页
1
<!
DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN"
>
2 < html >
3 < head >
4 < TITLE > 内容框架集 </ TITLE >
5 < META HTTP-EQUIV ="Content-Type" CONTENT ="text/html; charset=gb2312" >
6 < meta name ="GENERATOR" content ="Microsoft Visual Studio .NET 7.1" >
7 < meta content ="http://schemas.microsoft.com/intellisense/ie5" name ="vs_targetSchema" >
8 </ head >
9 < frameset cols ="150,*" >
10 < frame name ="contents" src ="treedrpLeft.aspx" >
11 < frame name ="main" src ="treeDrpRight.aspx" >
12 < noframes >
13 < pre id ="p2" >
14 ================================================================
15 关于完成此内容框架集的说明
16 1. 为“contents”框架添加 src="" 页的 URL。
17 2. 为“main”框架添加 src="" 页的 URL。
18 3. 将 BASE target="main" 元素添加到“contents”页的
19 HEAD,以将“main”设置为默认框架,“contents”页的链接将
20 在该框架中显示其他页。
21 ================================================================
22 </ pre >
23 < p id ="p1" >
24 此 HTML 框架集显示多个 Web 页。若要查看此框架集,请使用支持 HTML 4.0 及更高版本的 Web 浏览器。
25 </ p >
26 </ noframes >
27 </ frameset >
28 </ html >
29
2 < html >
3 < head >
4 < TITLE > 内容框架集 </ TITLE >
5 < META HTTP-EQUIV ="Content-Type" CONTENT ="text/html; charset=gb2312" >
6 < meta name ="GENERATOR" content ="Microsoft Visual Studio .NET 7.1" >
7 < meta content ="http://schemas.microsoft.com/intellisense/ie5" name ="vs_targetSchema" >
8 </ head >
9 < frameset cols ="150,*" >
10 < frame name ="contents" src ="treedrpLeft.aspx" >
11 < frame name ="main" src ="treeDrpRight.aspx" >
12 < noframes >
13 < pre id ="p2" >
14 ================================================================
15 关于完成此内容框架集的说明
16 1. 为“contents”框架添加 src="" 页的 URL。
17 2. 为“main”框架添加 src="" 页的 URL。
18 3. 将 BASE target="main" 元素添加到“contents”页的
19 HEAD,以将“main”设置为默认框架,“contents”页的链接将
20 在该框架中显示其他页。
21 ================================================================
22 </ pre >
23 < p id ="p1" >
24 此 HTML 框架集显示多个 Web 页。若要查看此框架集,请使用支持 HTML 4.0 及更高版本的 Web 浏览器。
25 </ p >
26 </ noframes >
27 </ frameset >
28 </ html >
29
左框架页中 有个TreeView
<
body
MS_POSITIONING
="GridLayout"
>
< form id ="Form1" method ="post" runat ="server" >
< iewc:TreeView id ="TreeView1" style ="Z-INDEX: 101; LEFT: 8px; POSITION: absolute; TOP: 80px" runat ="server" >
< iewc:TreeNode Text ="Node0" >
< iewc:TreeNode Text ="Node0" ></ iewc:TreeNode >
</ iewc:TreeNode >
< iewc:TreeNode Text ="Node1" ></ iewc:TreeNode >
< iewc:TreeNode Text ="Node2" ></ iewc:TreeNode >
< iewc:TreeNode Text ="Node3" ></ iewc:TreeNode >
</ iewc:TreeView >
</ form >
</ body >
< form id ="Form1" method ="post" runat ="server" >
< iewc:TreeView id ="TreeView1" style ="Z-INDEX: 101; LEFT: 8px; POSITION: absolute; TOP: 80px" runat ="server" >
< iewc:TreeNode Text ="Node0" >
< iewc:TreeNode Text ="Node0" ></ iewc:TreeNode >
</ iewc:TreeNode >
< iewc:TreeNode Text ="Node1" ></ iewc:TreeNode >
< iewc:TreeNode Text ="Node2" ></ iewc:TreeNode >
< iewc:TreeNode Text ="Node3" ></ iewc:TreeNode >
</ iewc:TreeView >
</ form >
</ body >
Private
Sub Page_Load()
Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
If Not IsPostBack Then
Dim i As Int16
For i = 0 To TreeView1.Nodes.Count - 1
TreeView1.Nodes(i).NavigateUrl = "treedrpRight.aspx?nid=" + TreeView1.Nodes(i).Text
TreeView1.Nodes(i).Target = "main"
Next
End If
End Sub
If Not IsPostBack Then
Dim i As Int16
For i = 0 To TreeView1.Nodes.Count - 1
TreeView1.Nodes(i).NavigateUrl = "treedrpRight.aspx?nid=" + TreeView1.Nodes(i).Text
TreeView1.Nodes(i).Target = "main"
Next
End If
End Sub
右框架
<%
@ Page Language="vb" AutoEventWireup="false" Codebehind="treeDrpRight.aspx.vb" Inherits="Ex.treeDrpRight"
%>
<! DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
< HTML >
< HEAD >
< title > treeDrpRight </ title >
< meta name ="GENERATOR" content ="Microsoft Visual Studio .NET 7.1" >
< meta name ="CODE_LANGUAGE" content ="Visual Basic .NET 7.1" >
< meta name ="vs_defaultClientScript" content ="JavaScript" >
< meta name ="vs_targetSchema" content ="http://schemas.microsoft.com/intellisense/ie5" >
</ HEAD >
< body MS_POSITIONING ="GridLayout" >
< form id ="Form1" method ="post" runat ="server" >
< asp:DropDownList id ="ddl" style ="Z-INDEX: 101; LEFT: 32px; POSITION: absolute; TOP: 80px" runat ="server"
Width ="136px" ></ asp:DropDownList >
</ form >
</ body >
</ HTML >
<! DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
< HTML >
< HEAD >
< title > treeDrpRight </ title >
< meta name ="GENERATOR" content ="Microsoft Visual Studio .NET 7.1" >
< meta name ="CODE_LANGUAGE" content ="Visual Basic .NET 7.1" >
< meta name ="vs_defaultClientScript" content ="JavaScript" >
< meta name ="vs_targetSchema" content ="http://schemas.microsoft.com/intellisense/ie5" >
</ HEAD >
< body MS_POSITIONING ="GridLayout" >
< form id ="Form1" method ="post" runat ="server" >
< asp:DropDownList id ="ddl" style ="Z-INDEX: 101; LEFT: 32px; POSITION: absolute; TOP: 80px" runat ="server"
Width ="136px" ></ asp:DropDownList >
</ form >
</ body >
</ HTML >
Private
Sub Page_Load()
Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
If Not IsPostBack Then
bind(Request("nid"))
End If
End Sub
Sub bind() Sub bind(ByVal n)
ddl.Items.Clear()
Dim i As Int16
For i = 0 To 5
Dim li As New ListItem(n + CStr(i), i)
ddl.Items.Add(li)
Next
End Sub
If Not IsPostBack Then
bind(Request("nid"))
End If
End Sub
Sub bind() Sub bind(ByVal n)
ddl.Items.Clear()
Dim i As Int16
For i = 0 To 5
Dim li As New ListItem(n + CStr(i), i)
ddl.Items.Add(li)
Next
End Sub