SiteMapPath.RootNodeStyle 属性

定义

获取根节点显示文本的样式。

public:
 property System::Web::UI::WebControls::Style ^ RootNodeStyle { System::Web::UI::WebControls::Style ^ get(); };
[System.Web.UI.PersistenceMode(System.Web.UI.PersistenceMode.InnerProperty)]
public System.Web.UI.WebControls.Style RootNodeStyle { get; }
[<System.Web.UI.PersistenceMode(System.Web.UI.PersistenceMode.InnerProperty)>]
member this.RootNodeStyle : System.Web.UI.WebControls.Style
Public ReadOnly Property RootNodeStyle As Style

属性值

Style

Style,它包含 SiteMapPath 控件根节点显示文本的样式设置。

属性

示例

下面的代码示例演示如何在控件上SiteMapPath以声明方式设置RootNodeStyle属性。

重要

此示例具有一个接受用户输入的文本框,这是一个潜在的安全威胁。 默认情况下,ASP.NET 网页验证用户输入是否不包含脚本或 HTML 元素。 有关详细信息,请参阅脚本侵入概述

<%@ Page language="c#"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
  <head runat="server">
    <title>ASP.NET Example</title>
</head>
<body>
    <form id="Form1" method="post" runat="server">

      <p><asp:SiteMapPath runat="server" ID="SiteMapPath1"
            RootNodeStyle-Font-Bold="true"
            RootNodeStyle-Font-Names="Arial Black"
            RootNodeStyle-Font-Italic="True"
            RootNodeStyle-ForeColor="Green"
            CurrentNodeStyle-ForeColor="Orange"/></p>

      <p><asp:Label
            id="Label1"
            runat="server"
            Width="441px"
            Height="64px"
            AssociatedControlID="TextBox1">
                Enter your customer service issue in the space
                provided below, and we will get back to you as
                soon as possible.</asp:Label></p>

      <p><asp:TextBox id="TextBox1" runat="server"
          Width="448px" Height="96px"></asp:TextBox></p>

      <p><asp:Button id="Button1" runat="server"
          Width="112px" Text="Submit"></asp:Button></p>
    </form>
  </body>
</html>
<%@ Page language="VB"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
  <head runat="server">
    <title>ASP.NET Example</title>
</head>
<body>
    <form id="Form1" method="post" runat="server">

      <p><asp:SiteMapPath runat="server" ID="SiteMapPath1"
            RootNodeStyle-Font-Bold="true"
            RootNodeStyle-Font-Names="Arial Black"
            RootNodeStyle-Font-Italic="True"
            RootNodeStyle-ForeColor="Green"
            CurrentNodeStyle-ForeColor="Orange"/></p>

      <p><asp:Label
            id="Label1"
            runat="server"
            Width="441px"
            AssociatedControlID="TextBox1"
            Height="64px">Enter your customer service issue in the space
                          provided below, and we will get back to you as
                          soon as possible.</asp:Label></p>

      <p><asp:TextBox id="TextBox1" runat="server"
          Width="448px" Height="96px"></asp:TextBox></p>

      <p><asp:Button id="Button1" runat="server"
          Width="112px" Text="Submit"></asp:Button></p>
    </form>
  </body>
</html>

注解

RootNodeStyle使用属性控制导航路径根节点的显示文本的外观。 默认情况下,显示文本是在表示页面的属性SiteMapNode中指定的Title。 常见样式设置包括自定义背景色、前景颜色、字体属性和节点间距。

对于 SiteMapPath 节点,样式属性按以下顺序合并为单个样式:

  1. NodeStyle

  2. CurrentNodeStyleRootNodeStyle,具体取决于节点类型。

备注

如果将节点字体样式设置为删除线或超行样式,则不会显示节点的默认下划线样式,除非显式设置为 true该样式。

如果定义了属性 RootNodeTemplate ,则忽略该 RootNodeStyle 属性。

适用于

另请参阅