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
|
/// <summary>
/// Output the HTML to render a node and optionally fill in its children.
/// </summary>
/// <param name="writer"></param>
/// <param name="treeID"></param>
/// <param name="delayLoad"></param>
public void WriteNode(HtmlTextWriter writer, string treeID, bool delayLoad)
{
// Work out which of plus, minus or empty to show.
String plusImg = "../../../images/plus.gif";
if (this.Children.Count == 0)
plusImg = "../../../images/transparent.gif";
else if (this.expanded)
plusImg = "../../../images/minus.gif";
// Show the child if it is expanded
String displayChild = "block";
if (!this.Expanded)
displayChild = "none";
// Set up for the delay load call if the node is not loaded at this time
string expand = String.Format("javascript:Toggle('{0}');", this.ID);
if (!this.expanded && delayLoad)
expand = String.Format("javascript:DelayLoadNode('{0}', '{1}');", treeID, this.ID);
writer.Write("<table border=\"0\" cellpadding=\"1\" cellspacing=\"1\"><tr>");
writer.Write(String.Format("<td width=\"16\"><a id=\"P{0}\" href=\"{1}\">", this.ID, expand));
writer.Write(String.Format("<img src='img/{0}' width='16' height='16' hspace='0' vspace='0' border='0'/>", plusImg));
writer.Write("</a></td>");
writer.Write(String.Format("<td nowrap=\"true\"><a id=\"P{0}\" href=\"{1}\">{2}</a>", this.ID, expand, this.Text, "</td>"));
writer.Write("</table>");
// Content holder for the child nodes
writer.Write(String.Format("<div style=\"display:{1};margin-left:2em\" id=\"D{0}\">", this.ID, displayChild));
// And do the children only if we are not delay loading.
if (!delayLoad)
{
foreach (TreeNode child in this.Children)
{
child.WriteNode(writer, treeID, delayLoad);
}
}
writer.Write(String.Format("</div>"));
} |
Partager