I have the following code and no matter what I try to do, it seems the ImageUrl on the SelectedNodeStyle is ignored. Am I doing something backwards?
Note that this thread is a continuation of ASP.Net TreeView with SiteMap is ignoring Node.开发者_JAVA技巧Selected which asked a different question and revealed this new question.
<asp:SiteMapDataSource ID="SiteMapDataSource1" runat="server" />
<asp:TreeView ID="TreeView1" runat="server" DataSourceID="SiteMapDataSource1">
<NodeStyle ForeColor="White" Font-Bold="true" NodeSpacing="5"
HorizontalPadding="5" ImageUrl="~/Images/Page.png" />
<SelectedNodeStyle Font-Bold="true" NodeSpacing="5"
HorizontalPadding="5" ImageUrl="~/Images/Page_Hot.png"/>
<HoverNodeStyle ForeColor="Navy" />
</asp:TreeView>
In the sample above, the selected node underlining works just perfectly. However, the image never changes. Yes, I double-checked the image was named correctly. It changes the other style attributes, just not the image. Quite frustrating.
Solution?
This seems to be a bug and goes back a few years (~2005, 2006). (Excuse the link-filled answer)
http://forums.asp.net/t/943367.aspx http://connect.microsoft.com/VisualStudio/feedback/details/104297/treeview-selectednodestyle-imageurl-not-working
I would set it in code-behind instead.
精彩评论