html代码<%@ Page language="c#" Codebehind="MainWebForm.aspx.cs" AutoEventWireup="false" Inherits="CusManageSystem.MainWebForm" %>
<%@ Register TagPrefix="iewc" Namespace="Microsoft.Web.UI.WebControls" Assembly="Microsoft.Web.UI.WebControls, Version=1.0.2.226, Culture=neutral, PublicKeyToken=31bf3856ad364e35" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
<HEAD>
<title>MainWebForm</title>
<meta content="Microsoft Visual Studio 7.0" name="GENERATOR">
<meta content="C#" name="CODE_LANGUAGE">
<meta content="JavaScript" name="vs_defaultClientScript">
<meta content="http://schemas.microsoft.com/intellisense/ie5" name="vs_targetSchema">
<script language="javascript">
<!--
function TrvModel_DblClick()
{
window.document.MainWebForm.Isdbclick.value='true';
window.document.MainWebForm.submit();
}
-->
</script>
</HEAD>
<BODY language="javascript" onclick="return window_onclick()">
<form id="MainWebForm" method="post" runat="server">
<FONT face="宋体"> <iframe style="Z-INDEX: 103; LEFT: 173px; WIDTH: 563px; POSITION: absolute; TOP: 68px; HEIGHT: 78.36%" name="MainArea" align="left" hspace="0" vspace="0" src="FLashWebForm.aspx" frameBorder="0" width="778" scrolling="auto" height="100%">
</iframe>
<asp:button id="Button1" style="Z-INDEX: 104; LEFT: 474px; POSITION: absolute; TOP: 8px" runat="server" Height="23px" Width="87px" Text="系统管理" BorderStyle="Solid"></asp:button>
<iewc:treeview id="TreeView1" ondblclick="TrvModel_DblClick()" style="Z-INDEX: 105; LEFT: 7px; POSITION: absolute; TOP: 67px" runat="server" Height="285px" Width="164px" BackColor="Silver" ExpandLevel="2">
<iewc:TreeNode ImageUrl="UsrPicture/button-help.gif" Text="系统管理" Expanded="True"></iewc:TreeNode>
</iewc:treeview><asp:button id="Button2" style="Z-INDEX: 106; LEFT: 377px; POSITION: absolute; TOP: 8px" runat="server" Height="23px" Width="97px" Text="走访处理" BorderStyle="Solid"></asp:button>
<INPUT id="Isdbclick" type="text" value="false" name="Isdbclick"> </FONT>
</form>
</BODY>
</HTML>
C#代码 Microsoft.Web.UI.WebControls.TreeNode node32=new Microsoft.Web.UI.WebControls.TreeNode();
node3.Nodes.Add(node32);
node32.Text="查询走访计划";
node32.NavigateUrl=@"VisitManage\VisitPlanManage\FINDPLAN.aspx";
node32.Target="MainArea";//这句非常重要
<%@ Register TagPrefix="iewc" Namespace="Microsoft.Web.UI.WebControls" Assembly="Microsoft.Web.UI.WebControls, Version=1.0.2.226, Culture=neutral, PublicKeyToken=31bf3856ad364e35" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
<HEAD>
<title>MainWebForm</title>
<meta content="Microsoft Visual Studio 7.0" name="GENERATOR">
<meta content="C#" name="CODE_LANGUAGE">
<meta content="JavaScript" name="vs_defaultClientScript">
<meta content="http://schemas.microsoft.com/intellisense/ie5" name="vs_targetSchema">
<script language="javascript">
<!--
function TrvModel_DblClick()
{
window.document.MainWebForm.Isdbclick.value='true';
window.document.MainWebForm.submit();
}
-->
</script>
</HEAD>
<BODY language="javascript" onclick="return window_onclick()">
<form id="MainWebForm" method="post" runat="server">
<FONT face="宋体"> <iframe style="Z-INDEX: 103; LEFT: 173px; WIDTH: 563px; POSITION: absolute; TOP: 68px; HEIGHT: 78.36%" name="MainArea" align="left" hspace="0" vspace="0" src="FLashWebForm.aspx" frameBorder="0" width="778" scrolling="auto" height="100%">
</iframe>
<asp:button id="Button1" style="Z-INDEX: 104; LEFT: 474px; POSITION: absolute; TOP: 8px" runat="server" Height="23px" Width="87px" Text="系统管理" BorderStyle="Solid"></asp:button>
<iewc:treeview id="TreeView1" ondblclick="TrvModel_DblClick()" style="Z-INDEX: 105; LEFT: 7px; POSITION: absolute; TOP: 67px" runat="server" Height="285px" Width="164px" BackColor="Silver" ExpandLevel="2">
<iewc:TreeNode ImageUrl="UsrPicture/button-help.gif" Text="系统管理" Expanded="True"></iewc:TreeNode>
</iewc:treeview><asp:button id="Button2" style="Z-INDEX: 106; LEFT: 377px; POSITION: absolute; TOP: 8px" runat="server" Height="23px" Width="97px" Text="走访处理" BorderStyle="Solid"></asp:button>
<INPUT id="Isdbclick" type="text" value="false" name="Isdbclick"> </FONT>
</form>
</BODY>
</HTML>
C#代码 Microsoft.Web.UI.WebControls.TreeNode node32=new Microsoft.Web.UI.WebControls.TreeNode();
node3.Nodes.Add(node32);
node32.Text="查询走访计划";
node32.NavigateUrl=@"VisitManage\VisitPlanManage\FINDPLAN.aspx";
node32.Target="MainArea";//这句非常重要
解决方案 »
- vs2008水晶报表 异常消息: Load report failed
- # jxyxhz # (小虎) repeater后台也能拼?
- 一个类能包含自身作为数据成员吗?
- Repeater 控件中怎样使用if语句?
- webForm中的两个radioButton怎么才能相互排斥?
- asp.net中如何使用web方式提交用户名和密码去通过域的验证?
- 嘿嘿,我散分,关于xml
- 用System.Drawing 怎样画出虚线
- 如何动态生成变量和方法?
- 救命啊!!小女子快要不行了!!如何实现树形并可以在上面右击显示菜单
- 绑定数据到dropdownlist的问题?
- 在线请看源程序~~代码也能运行~但是和书上的效果不一样~请看程序那的问题
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Data.OleDb;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;namespace myoa
{
/// <summary>
/// WebForm1 的摘要说明。
/// </summary>
public class WebForm1 : System.Web.UI.Page
{
protected System.Data.OleDb.OleDbConnection oleDbConnection1;
protected System.Data.OleDb.OleDbDataAdapter oleDbDataAdapter1;
protected System.Data.DataSet dataSet1;
protected Microsoft.Web.UI.WebControls.TreeView TreeView1;
DataSet ds=new DataSet();
public string objConn;
//public string objConn ="Provider=Microsoft.Jet.OLEDB.4.0; Data Source="+"\\dATABASE\\myoa.mdb";
OleDbConnection MyConn;
OleDbDataAdapter mycommand; private void Page_Load(object sender, System.EventArgs e)
{
// 在此处放置用户代码以初始化页面
//TreeView1.Width=100;
//TreeView1.Height=450;
objConn ="Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" + Server.MapPath("dATABASE\\myoa.mdb");
string NodeText="-1";
MyConn=new OleDbConnection(objConn);
mycommand=new OleDbDataAdapter("select * from tree where TreeNode='"+NodeText+"' order by NodeNumber asc",MyConn);
MyConn.Open();
mycommand.Fill(ds);
int i;
//===根结点数
for(i=0;i<ds.Tables[0].Rows.Count;i++)
{
Microsoft.Web.UI.WebControls.TreeNode myTreeNode=new Microsoft.Web.UI.WebControls.TreeNode();
//dim myTreeNode as new Microsoft.Web.UI.WebControls.TreeNode()
myTreeNode.Text=ds.Tables[0].Rows[i].ItemArray[1].ToString() ;
myTreeNode.ImageUrl="images/closedfolder.gif";
myTreeNode.ExpandedImageUrl="images/openfolder.gif";
myTreeNode.NavigateUrl="Query.aspx?NodeText="+myTreeNode.Text;
myTreeNode.Target="mainFrame";
TreeView1.Nodes.Add(myTreeNode);
//Response.Write( ds.Tables[0].Rows[i].ItemArray[0].ToString());
//Response.Write("<br/>");
//Response.Write( ds.Tables[0].Rows[i].ItemArray[1].ToString());
CreateChildTree(myTreeNode,ds.Tables[0].Rows[i].ItemArray[0].ToString() ,ds.Tables[0].Rows[i].ItemArray[1].ToString() );
}
//end sub
}
public void CreateChildTree(Microsoft.Web.UI.WebControls.TreeNode ParentNode,string NodeId ,string ParentNodeText)
{
mycommand=new OleDbDataAdapter("select * from tree where TreeNode='"+NodeId+"' order by NodeNumber desc",MyConn);
//MyConn.Open();
mycommand.Fill(ds,"second");
int i;
for(i=0;i<ds.Tables["second"].Rows.Count;i++)
{
Microsoft.Web.UI.WebControls.TreeNode myTreeNode=new Microsoft.Web.UI.WebControls.TreeNode();
myTreeNode.Text=ds.Tables["second"].Rows[i].ItemArray[1].ToString();
myTreeNode.ImageUrl="images/book.gif";
string myTreeNodeText =myTreeNode.Text;
string ParentNodeTextS =ParentNodeText;
//myTreeNodeText=Server.UrlEncode(myTreeNodeText);
//ParentNodeTextS=Server.UrlEncode(ParentNodeTextS);
myTreeNode.NavigateUrl="Query.aspx?NodeText="+myTreeNodeText+"&ParentNodeText="+ParentNodeTextS;
myTreeNode.Target="mainFrame";
ParentNode.Nodes.Add(myTreeNode);
}
ds.Tables["second"].Clear();
} #region Web Form Designer generated code
override protected void OnInit(EventArgs e)
{
//
// CODEGEN:该调用是 ASP.NET Web 窗体设计器所必需的。
//
InitializeComponent();
base.OnInit(e);
}
/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.oleDbConnection1 = new System.Data.OleDb.OleDbConnection();
this.oleDbDataAdapter1 = new System.Data.OleDb.OleDbDataAdapter();
this.dataSet1 = new System.Data.DataSet();
((System.ComponentModel.ISupportInitialize)(this.dataSet1)).BeginInit();
//
// dataSet1
//
this.dataSet1.DataSetName = "NewDataSet";
this.dataSet1.Locale = new System.Globalization.CultureInfo("zh-CN");
this.Load += new System.EventHandler(this.Page_Load);
((System.ComponentModel.ISupportInitialize)(this.dataSet1)).EndInit(); }
#endregion
} //public Sub resize()
}
Private Sub initTree(ByVal nds As TreeNodeCollection, ByVal parentID As Integer)
Dim dv As New DataView()
Dim tmpNd As TreeNode
Dim strId As Integer
dv.Table = ds.Tables("TitleTree")
dv.RowFilter = "parentid='" + parentID.ToString() + "'"
Dim objRow As DataRowView For Each objRow In dv
tmpNd = New TreeNode()
strId = CInt(objRow("nodeid"))
tmpNd.ID = strId.ToString()
tmpNd.Text = objRow("nodename").ToString()
tmpNd.ExpandedImageUrl = objRow("imgex").ToString()
tmpNd.ImageUrl = objRow("img").ToString()
tmpNd.NavigateUrl = objRow("address").ToString()
nds.Add(tmpNd)
initTree(nds(nds.Count - 1).Nodes, strId)
Next End Sub生成节点表的脚本文件:
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[visit_TitleTree]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[visit_TitleTree]
GOCREATE TABLE [dbo].[visit_TitleTree] (
[parentid] [varchar] (50) COLLATE Chinese_PRC_CI_AS NOT NULL ,
[nodeid] [varchar] (50) COLLATE Chinese_PRC_CI_AS NOT NULL ,
[nodename] [varchar] (50) COLLATE Chinese_PRC_CI_AS NULL ,
[imgex] [varchar] (50) COLLATE Chinese_PRC_CI_AS NULL ,
[img] [varchar] (50) COLLATE Chinese_PRC_CI_AS NULL ,
[address] [varchar] (100) COLLATE Chinese_PRC_CI_AS NULL
) ON [PRIMARY]
GO
那么,你在tree.aspx的html视图中的<head></head>之间加上
<script language="javascript">
function ShowContents1()
{
parent.Right.location.href="right.aspx";
//其中Right是右边框架的name属性,parent就是FRAME了
} </script>
其中,frame框架试这样的,
<%@ Page language="c#" Codebehind="MainForm.aspx.cs" AutoEventWireup="false" Inherits="PlanTask.MainForm" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
<HEAD>
<TITLE>MainForm</TITLE>
<meta content="Microsoft Visual Studio 7.0" name="GENERATOR">
<meta content="C#" name="CODE_LANGUAGE">
<meta content="JavaScript" name="vs_defaultClientScript">
<meta content="http://schemas.microsoft.com/intellisense/ie5" name="vs_targetSchema">
</HEAD>
<frameset cols="171,77%">
<frame name="Tree" src="tree.aspx">
<frame name="Right">
</frameset>
</HTML>
然后,只要在tree.aspx的html视图中设置
TreeNode NavigateUrl="javascript:ShowContents1()"就行了