<%@ Page language="c#" src="TreeFrame.aspx.cs" AutoEventWireup="false" Inherits="TreeFrame" %>
<%@ Register TagPrefix="iewc" Namespace="Microsoft.Web.UI.WebControls" Assembly="Microsoft.Web.UI.WebControls" %>
<HTML>
<body>
<form id="Form1" method="post" runat="server">
<iewc:TreeView id="TreeView1" style="Z-INDEX: 101; LEFT: 8px; POSITION: absolute; TOP: 8px" runat="server"
Width="228px" Height="363px" AutoPostBack="True" BorderStyle="None" BorderWidth="2px" Indent="15">
<iewc:TreeNodeType ImageUrl="folder.gif" Type="Folder"></iewc:TreeNodeType>
<iewc:TreeNodeType ImageUrl="page.gif" Type="Page"></iewc:TreeNodeType>
</iewc:TreeView>
<asp:Label id="Label1" style="Z-INDEX: 102; LEFT: 20px; POSITION: absolute; TOP: 264px" runat="server"
Height="80px" Width="102px">Note: None of the links under My Site will work, because these pages do not exist.</asp:Label>
</form>
</body>
</HTML>
<%--
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using Microsoft.Web.UI.WebControls;
public class TreeFrame : System.Web.UI.Page
{
protected System.Web.UI.WebControls.Label Label1;
protected Microsoft.Web.UI.WebControls.TreeView TreeView1;
private void Page_Load(object sender, System.EventArgs e)
{
if (!this.IsPostBack)
{
Microsoft.Web.UI.WebControls.TreeNode rootNode;
rootNode = AddNode("default.aspx", "My Site", "Folder",
TreeView1.Nodes);
AddNode("info.aspx", "Contact Page", "Page", rootNode.Nodes) ;
rootNode.Expanded = true;
rootNode = AddNode("links.aspx", "Links", "Folder",
TreeView1.Nodes);
AddNode("http://www.google.com", "Google", "Page",
rootNode.Nodes);
AddNode("http://www.java2java.com", "java2s.com", "Page", rootNode.Nodes);
AddNode("http://www.google.com", "Google", "Page",
rootNode.Nodes);
rootNode.Expanded = true;
}
}
private Microsoft.Web.UI.WebControls.TreeNode AddNode(string id, string text,
string type, Microsoft.Web.UI.WebControls.TreeNodeCollection nodeCollection)
{
Microsoft.Web.UI.WebControls.TreeNode node = new Microsoft.Web.UI.WebControls.TreeNode();
node.Text = text;
node.Type = type;
node.ID = id;
nodeCollection.Add(node);
return node;
}
#region Web Form Designer generated code
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: This call is required by the ASP.NET Web Form Designer.
//
InitializeComponent();
base.OnInit(e);
}
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.TreeView1.SelectedIndexChange += new Microsoft.Web.UI.WebControls.SelectEventHandler(this.TreeView1_SelectedIndexChange);
this.Load += new System.EventHandler(this.Page_Load);
}
#endregion
private void TreeView1_SelectedIndexChange(object sender, Microsoft.Web.UI.WebControls.TreeViewSelectEventArgs e)
{
Microsoft.Web.UI.WebControls.TreeNode selectedNode = TreeView1.GetNodeFromIndex(e.NewNode);
string url = selectedNode.ID;
// Use JavaScript to trigger the redirect in the other window.
string frameScript = "<script language='javascript'>" +
"window.parent.frames(1).location='" + url + "';" + "</script>";
Page.RegisterStartupScript("FrameScript", frameScript);
}
}
--%>
|