开发者

Asp.net 4 TreeView SelectedNodeStyle ImageUrl seems to be ignored

开发者 https://www.devze.com 2023-03-13 03:28 出处:网络
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?

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消