0
votes

I have added one TreeView control in my ASP.NET page.when i seeing the aspx file, it's forecolor is set to black color.But when i seeing in the browser then it is changed to blue color by default.

i want to display tree node forecolor in black color only...

This is my Code...

 <asp:TreeView ID="TreeView1" runat="server" ImageSet="Arrows" 
                                    ExpandDepth="0" ShowCheckBoxes="None" onselectednodechanged="TreeView1_SelectedNodeChanged" 
                                    style="margin-left: 5px" Font-Names="Verdana" ForeColor="Black" NodeWrap="True" 
                                    Height="250px" NodeStyle-CssClass="Color" Width="275px" Font-Size="X-Small" >
                                </asp:TreeView>

Please guide me to get out of this issue...

2

2 Answers

2
votes

Try this :

<asp:TreeView ID="tree1" runat="server">
            <Nodes>
                <asp:TreeNode Text="A"></asp:TreeNode>
                <asp:TreeNode Text="B"></asp:TreeNode>
                <asp:TreeNode Text="C"></asp:TreeNode>
            </Nodes>
            <NodeStyle CssClass="Color" />
        </asp:TreeView>



<style type="text/css">
        .Color{
            color:black !important;
        }
    </style>

Thanks

1
votes

Try this

Whenever you add the node named childNode, you have to set the property called SelectAction as given below

childNode.SelectAction = TreeNodeSelectAction.None;

By default the SelectAction will be select, because of that you will getting the hyperlink that is blue colour to your text.

If your adding those elements in static do it this way

<Nodes>


 <asp:TreeNode Text="Node1" SelectAction="None"></asp:TreeNode>

</Nodes>

Hope it helps!!!