ASP.NET TreeNode SelectedNodeStyle having no effect
I have created a treeview to which I am dynamically adding values to. Everything seems to work fine - the selected event is being triggered and the treeview works perfectly. The only problem is that changing the selectednodestyle has no effect on the treeview.
Please help I have been researching this problem for quite a while now.
This is the html code for my treeview:
<asp:TreeView ID="treeViewProperties" runat="server" OnSelectedNodeChanged="TreeViewPropertiesNodeSelected" Font-Bold="False" NodeIndent="10" ShowExpandCollapse="False">
<HoverNodeStyle Font-Bold="False" Font-Strikeout="False" Font-Underline="False" ForeColor="Goldenrod" />
<开发者_StackOverflow中文版NodeStyle Font-Names="Arial" Font-Size="9pt" ForeColor="White" HorizontalPadding="0px" NodeSpacing="0px" VerticalPadding="2px" />
<ParentNodeStyle Font-Bold="False" />
<RootNodeStyle Font-Bold="True" />
<SelectedNodeStyle BackColor="#FF33CC" ForeColor="#FF3399" Height="500px" />
</asp:TreeView>
I ended up solving this with Jquery.
I added a click event to the treeviewproperties nodes and added styling to the selected treenode.
here is the code:
$(function () {
$('.MainContent_treeViewProperties_3').click(function () {
$(".MainContent_treeViewProperties_3").css('color', 'white');
$(this).css('color', '#273F6F');
});
$('.MainContent_treeViewProperties_1').click(function () {
$(".MainContent_treeViewProperties_1").css('text-decoration', '');
if ($(this).is('.MainContent_treeViewProperties_3')) {
// This is a root node do not change its color.
}
else {
$(this).css('text-decoration', 'underline');
}
});
});
精彩评论