下面的代码示例演示如何使用 ParentNodeStyle 属性控制 TreeView 控件中父节点的外观。
view plaincopy to clipboardprint ?
<% @ Page Language = " C# " %>
< HTML >
< FORM runat = " server " >
< H3 > TreeView ParentNodeStyle Example </ H3 >
<!-- Declaratively set the ParentNodeStyle settings. -->
< ASP:TREEVIEW id = LinksTreeView runat = " server " ParentNodeStyle - VerticalPadding = " 0 " ParentNodeStyle - ForeColor = " Green " >
< NODES >
< ASP:TREENODE Text = " Home " Expanded = " True " Target = " Content " NavigateUrl = " Home.aspx " Value = " Home " >
< ASP:TREENODE Text = " Page1 " Target = " Content " NavigateUrl = " Page1.aspx " Value = " Page 1 " >
< ASP:TREENODE Text = " Section 1 " Target = " Content " NavigateUrl = " Section1.aspx " Value = " Section 1 " />
</ ASP:TREENODE >
< ASP:TREENODE Text = " Page 2 " Target = " Content " NavigateUrl = " Page2.aspx " Value = " Page 2 " >
</ ASP:TREENODE >
</ ASP:TREENODE >
</ NODES >
</ ASP:TREEVIEW >
</ FORM >
view plaincopy to clipboardprint ?
<% @ Page Language = " C# " %>
< HTML >
< FORM runat = " server " >
< H3 > TreeView ParentNodeStyle Example </ H3 >
<!-- Declaratively set the ParentNodeStyle settings. -->
< ASP:TREEVIEW id = LinksTreeView runat = " server " ParentNodeStyle - VerticalPadding = " 0 " ParentNodeStyle - ForeColor = " Green " >
< NODES >
< ASP:TREENODE Text = " Home " Expanded = " True " Target = " Content " NavigateUrl = " Home.aspx " Value = " Home " >
< ASP:TREENODE Text = " Page1 " Target = " Content " NavigateUrl = " Page1.aspx " Value = " Page 1 " >
< ASP:TREENODE Text = " Section 1 " Target = " Content " NavigateUrl = " Section1.aspx " Value = " Section 1 " />
</ ASP:TREENODE >
< ASP:TREENODE Text = " Page 2 " Target = " Content " NavigateUrl = " Page2.aspx " Value = " Page 2 " >
</ ASP:TREENODE >
</ ASP:TREENODE >
</ NODES >
</ ASP:TREEVIEW >
</ FORM >