1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59
|
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Collections.Generic;
public partial class TreeView : System.Web.UI.UserControl
{
private Tree tree;
/// <summary>
/// Tree to display in the control
/// </summary>
public Tree DisplayTree
{
get { return tree; }
set { tree = value; }
}
private bool delayLoad = true;
/// <summary>
/// Set delay load if the output of the tree should be
/// staged using AJAX techniques.
/// </summary>
public bool DelayLoad
{
get { return delayLoad; }
set { delayLoad = value; }
}
protected void Page_Load(object sender, EventArgs e)
{
if (DisplayTree == null)
throw new HttpException("DisplayTree must not be null in tree build.");
// Store the tree data in the session to allow access at treefill time.
if (delayLoad)
Session["tree" + DisplayTree.ID] = DisplayTree;
}
protected override void Render(HtmlTextWriter writer)
{
// Reference javascript for AJAX behaviour and tree toggling
writer.Write("<script language=\"javascript\" type=\"text/javascript\" src=\"../../scripts/TreeToggle.js\"></script>");
// Write the root node
DisplayTree.Root.WriteNode(writer, DisplayTree.ID, delayLoad);
}
} |
Partager