Reputation: 11464
In a asp.net web site I'm using a TreeView
to display data from a xml
file
this is the TreeView HTML code
<asp:TreeView ID="trvPILDeepSearch" runat="server" ImageSet="Simple" BackColor="#F8F8F8" BorderWidth="5px" BorderColor="#F8F8F8" LeafNodeStyle-CssClass="leafnode" Width="600px" >
<DataBindings>
<asp:TreeNodeBinding DataMember="Parent" TextField="TEXT" SelectAction="None" />
<asp:TreeNodeBinding DataMember="Child" TextField="TEXT" SelectAction="None" />
</DataBindings>
</asp:TreeView>
Now I want to change the text color of the Parent nodes, Is it possible to change the colour only in selected nodes
Name1 <-- Change the color of this
Detail1
Detail2
Name2 <-- Change the color of this
Detail2
Detail2
Upvotes: 0
Views: 4722
Reputation: 4469
You can add RootNodeStyle
for the tree view:
/* Styles: put this at style section or at your .css file */
.rootNodeLinkStyle a:link
{
color: Red;
}
.rootNodeLinkStyle a:hover
{
color: pink;
text-decoration:underline;
}
In .aspx: add the css class to the RootNodeStyle
as below:
<asp:TreeView ID="trvPILDeepSearch" runat="server" ImageSet="Simple" BackColor="#F8F8F8" BorderWidth="5px" BorderColor="#F8F8F8" LeafNodeStyle-CssClass="leafnode" Width="600px" >
<DataBindings>
<asp:TreeNodeBinding DataMember="Parent" TextField="TEXT" SelectAction="None" />
<asp:TreeNodeBinding DataMember="Child" TextField="TEXT" SelectAction="None" />
</DataBindings>
<RootNodeStyle CssClass="rootNodeLinkStyle" />
</asp:TreeView>
Upvotes: 1