【问题标题】:Display Image to right of text in TreeView in asp.net在 asp.net 中的 TreeView 中的文本右侧显示图像
【发布时间】:2015-08-25 12:24:36
【问题描述】:

我有一个TreeView 来弹出我的菜单。默认情况下,当我将带有图像的新 TreeNode 添加到 TreeView 时,图像会出现在 TreeNode 文本的左侧。

我的aspx代码是

<asp:TreeView ID="TreeView1" runat="server" ImageSet="Arrows" ExpandDepth="1" NodeIndent="10"
        BackColor="White" Font-Bold="False" Font-Italic="False" Font-Names="Andalus"
        Font-Size="Small">
        <HoverNodeStyle Font-Underline="False" />
        <Nodes>
            <asp:TreeNode Text="Parent 1" Value="Print">
                <asp:TreeNode Text="Node 1" Value="01"></asp:TreeNode>
                <asp:TreeNode Text="Node 2" Value="02"></asp:TreeNode>
            </asp:TreeNode>
            <asp:TreeNode Text="Parent 2" Value="03"></asp:TreeNode>
            <asp:TreeNode Text="Parent 3" Value="04" ImageUrl="images/blinking_new.gif">
            </asp:TreeNode>                
            <asp:TreeNode Text="Parent 4" Value="05"></asp:TreeNode>
        </Nodes>
        <NodeStyle Font-Names="Verdana" Font-Size="8pt" ForeColor="Black" HorizontalPadding="5px"
            NodeSpacing="0px" VerticalPadding="0px" />
        <ParentNodeStyle Font-Bold="True" ForeColor="#5555DD" />
        <SelectedNodeStyle Font-Underline="True" HorizontalPadding="0px" VerticalPadding="0px"
            BackColor="#FF99CC" ImageUrl="" />
    </asp:TreeView>

输出是

但我希望图像应该出现在文本的右侧。

喜欢:

如何做到这一点? TreeNode 是否有任何属性可以做到这一点,或者我必须为此写一个css。 我也搜索了很多,但无法解决。

您的宝贵建议将不胜感激。

【问题讨论】:

  • 你能把图片放在treenode标签里面吗?我不确定,但也许它可以帮助你。
  • 不支持

标签: c# asp.net treeview treenode


【解决方案1】:

你能试试这个吗:

<asp:TreeNode Text="Parent 3" Value="04" ImageUrl="images/blinking_new.gif" class="new">
</asp:TreeNode>                

在你的 CSS 中

.new image { 
    float: right; 
    /*try maybe also to use relative position*/
}

【讨论】:

  • 谢谢。 TreeNode 没有属性 CssClass。但我已将其添加到 NodeStyle,但遗憾的是它没有用
  • 也许使用html属性class而不是asp类CssClass
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2019-05-29
  • 1970-01-01
  • 2014-09-02
  • 1970-01-01
  • 1970-01-01
  • 2011-06-24
  • 1970-01-01
相关资源
最近更新 更多