SiteMapPath.NodeStyle 属性

定义

获取用于站点导航路径中所有节点的显示文本的样式。Gets the style used for the display text for all nodes in the site navigation path.

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

属性值

Style

Style,它包含 SiteMapPath 控件中显示文本的样式设置。The Style that contains the style settings for the display text in the SiteMapPath control.

属性

示例

下面的代码示例演示如何定义 NodeStyle 与合并的, RootNodeStyle 以演示节点的样式优先级顺序 SiteMapPathThe following code example demonstrates how to define a NodeStyle that is merged with a RootNodeStyle to demonstrate the order of style precedence for the SiteMapPath nodes.

<%@ Page Language="C#" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<script runat="server">
</script>

<html xmlns="http://www.w3.org/1999/xhtml" >
    <head runat="server">
    <title>ASP.NET Example</title>
</head>
<body>
        <form id="form1" runat="server">

            <!-- The following example demonstrates some of the orders
                 of precedence when applying styles and templates to
                 functional nodes of a SiteMapPath.

                 The NodeStyle and RootNodeStyle define the same attributes,
                 but are different and conflict with each other: the
                 RootNodeStyle supersedes NodeStyle, and is the style
                 rendered. Notice, however, that the underline style
                 defined by NodeStyle is still applied.

                 Both a CurrentNodeStyle and a CurrentNodeTemplate are
                 defined. A template supersedes a style for a node
                 type, so CurrentNodeTemplate is displayed and CurrentNodeStyle
                 is ignored. -->

            <asp:SiteMapPath ID="SiteMapPath1" runat="server"
                RenderCurrentNodeAsLink="true"
                NodeStyle-Font-Names="Franklin Gothic Medium"
                NodeStyle-Font-Underline="true"
                NodeStyle-Font-Bold="true"
                RootNodeStyle-Font-Names="Symbol"
                RootNodeStyle-Font-Bold="false"
                CurrentNodeStyle-Font-Names="Verdana"
                CurrentNodeStyle-Font-Size="10pt"
                CurrentNodeStyle-Font-Bold="true"
                CurrentNodeStyle-ForeColor="red"
                CurrentNodeStyle-Font-Underline="false">
                <CURRENTNODETEMPLATE>
                        <asp:Image id="Image1" runat="server" ImageUrl="WebForm2.jpg" AlternateText="WebForm2"/>
                </CURRENTNODETEMPLATE>
            </asp:SiteMapPath>


        </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">

<script runat="server">
</script>

<html xmlns="http://www.w3.org/1999/xhtml" >
    <head runat="server">
    <title>ASP.NET Example</title>
</head>
<body>
        <form id="form1" runat="server">

            <!-- The following example demonstrates some of the orders
                 of precedence when applying styles and templates to
                 functional nodes of a SiteMapPath.

                 The NodeStyle and RootNodeStyle define the same attributes,
                 but are different and conflict with each other: the
                 RootNodeStyle supersedes NodeStyle, and is the style
                 rendered. Notice, however, that the underline style
                 defined by NodeStyle is still applied.

                 Both a CurrentNodeStyle and a CurrentNodeTemplate are
                 defined. A template supersedes a style for a node
                 type, so CurrentNodeTemplate is displayed and CurrentNodeStyle
                 is ignored. -->

            <asp:SiteMapPath ID="SiteMapPath1" runat="server"
                RenderCurrentNodeAsLink="true"
                NodeStyle-Font-Names="Franklin Gothic Medium"
                NodeStyle-Font-Underline="true"
                NodeStyle-Font-Bold="true"
                RootNodeStyle-Font-Names="Symbol"
                RootNodeStyle-Font-Bold="false"
                CurrentNodeStyle-Font-Names="Verdana"
                CurrentNodeStyle-Font-Size="10pt"
                CurrentNodeStyle-Font-Bold="true"
                CurrentNodeStyle-ForeColor="red"
                CurrentNodeStyle-Font-Underline="false">
                <CURRENTNODETEMPLATE>
                        <asp:Image id="Image1" runat="server" ImageUrl="WebForm2.jpg" AlternateText="WebForm2"/>
                </CURRENTNODETEMPLATE>
            </asp:SiteMapPath>


        </form>
    </body>
</html>

注解

使用 NodeStyle 属性可控制控件呈现的所有导航路径节点的显示文本外观。Use the NodeStyle property to control the appearance of the display text for all navigation path nodes rendered by the control. 默认情况下,显示文本是在 Title 表示页面的的属性中指定的 SiteMapNodeBy default, the display text is that specified in the Title property of the SiteMapNode that represents the page. 常用样式设置包括自定义背景色、前景颜色、字体属性和节点间距。Common style settings include custom background color, foreground color, font properties, and node spacing.

对于 SiteMapPath 节点,样式属性将按以下顺序合并为单个样式:For SiteMapPath nodes, style properties are merged into a single style, in the following order:

  1. NodeStyle

  2. CurrentNodeStyleRootNodeStyle ,具体取决于节点类型。CurrentNodeStyle or RootNodeStyle, depending on the node type.

备注

如果将节点字体样式设置为删除线或上划线样式,则不会显示节点的默认下划线样式,除非将其显式设置为 trueIf you set the node font style to a strikeout or overline style, the default underline style of the node is not displayed unless it is explicitly set to true.

如果 NodeStyle 定义了,则它最初应用于每个节点。If the NodeStyle is defined, it is initially applied to each node. 如果为特定类型的节点(如根节点或当前节点)定义了其他样式,则此样式将取代在属性中指定的常规样式 NodeStyleIf an additional style is defined for a particular type of node, such as the root node or current node, this style supersedes the general style specified in the NodeStyle property. 如果为特定类型的节点定义了模板,则它将取代该节点的所有已定义样式。If a template is defined for a particular type of node, it supersedes all defined styles for that node.

适用于

另请参阅