(Is loading VS2008, take this time to share the next small control, can not organize demo, only from the project copy part of the code)
JQuery simple TreeView needs such a piece of HTML
<ul class="filetree" id="treeFolder">
<li id="1"><span class="folder">Root</span>
<ul>
<li id="2" class="closed"><span class="folder">node1</span><ul></ul></li>
<li id="22" class="closed"><span class="folder">node2</span><ul></ul></li>
<li id="23" class="closed"><span class="folder">node3</span><ul></ul></li>
</ul>
</li>
<li id="64"><span class="imagebase">root2</span></li>
</ul>
Put an empty <ul></ul> on this side, because that node has a child node, but we did not load him, when the user clicks the expand button in the expansion. Expand the time to go to the server to take a data on their own add, here is no nonsense.
First code:
Using System;
Using System.Collections.Generic;
Using System.ComponentModel;
Using System.Text;
Using System.Web;
Using System.Web.UI;
Using System.Web.UI.WebControls;
Namespace aaa.bbb.ccc//to change his own
{
[Defaultproperty ("Text")]
[ToolBoxData ("<{0}:javascripttree runat=server></{0}:javascripttree>")]
public class Javascripttree:webcontrol
{
Private list<javascripttreenode> _nodes = new list<javascripttreenode> ();
Public list<javascripttreenode> Nodes
{
Set
{
_nodes = value;
}
Get
{
return _nodes;
}
}
private string _classname;
public string ClassName
{
Get
{
return _classname;
}
Set
{
_classname = value;
}
}
protected override void CreateChildControls ()
{
Base. CreateChildControls ();
foreach (Javascripttreenode item in _nodes)
{
Base. Controls.Add (item);
}
}
public override void RenderBeginTag (HtmlTextWriter writer)
{
Writer. WriteBeginTag ("div");
Writer. WriteAttribute ("Class", this.) ClassName);
Writer. WriteAttribute ("id", "div" + this.id);
Writer. Write (Htmltextwriter.tagrightchar);
Writer. WriteBeginTag ("ul");
Writer. WriteAttribute ("Class", this.) ClassName);
Writer. WriteAttribute ("id", this.id);
Writer. Write (Htmltextwriter.tagrightchar);
}
public override void RenderEndTag (HtmlTextWriter writer)
{
Writer. Writeendtag ("ul");
Writer. Writeendtag ("div");
}
protected override HtmlTextWriterTag Tagkey
{
Get
{
return htmltextwritertag.div;
}
}
}
}