Menu.IncludeStyleBlock 屬性

定義

取得或設定值,這個值表示 ASP.NET 是否應該針對功能表中使用的樣式,在階層式樣式表 (CSS) 定義中專門設立一個區塊。Gets or sets a value that indicates whether ASP.NET should render a block of cascading style sheet (CSS) definitions for the styles that are used in the menu.

public:
 property bool IncludeStyleBlock { bool get(); void set(bool value); };
public bool IncludeStyleBlock { get; set; }
member this.IncludeStyleBlock : bool with get, set
Public Property IncludeStyleBlock As Boolean

屬性值

Boolean

一個值,表示 ASP.NET 是否應該針對功能表中使用的樣式,在 CSS 定義中專門設立一個區塊。A value that indicates whether ASP.NET should render a block of CSS definitions for the styles that are used in the menu. 預設值是 trueThe default value is true.

備註

Menu控制項使用 CSS 樣式來控制其在瀏覽器中的外觀。The Menu control uses CSS styles to control its appearance in a browser. 根據預設,它會轉譯 style 元素,其中包含所使用之 css 類別的 css 定義。By default, it renders a style element that contains the CSS definitions for the CSS classes that it uses. 在下列情況下,您通常會將此屬性設定為 falseYou typically set this property to false in the following situations:

  • 您想要提供自己的 CSS 定義,以便自訂功能表的外觀。You want to provide your own CSS definitions in order to customize the appearance of the menu. 接著,您必須在頁面中提供自己的 CSS 定義區塊,或包含包含定義之外部 CSS 檔案的連結。You must then provide your own block of CSS definitions in the page, or include a link to an external CSS file that contains the definitions.

  • 您想要保留預設的外觀,但想要將產生的 CSS 定義保留在不同的檔案中。You want to keep the default appearance but prefer to keep the generated CSS definitions in a separate file. 接著,您必須提供檔案並連結至該檔案。You must then provide the file and link to it.

在上述任一情況下,您都可以取得控制項所產生的預設 CSS 區塊複本 Menu ,方法是將屬性設定為 true 、執行頁面,然後在瀏覽器中查看頁面。In either of these situations, you can get a copy of the default CSS block that the Menu control generates by setting the property to true, running the page, and viewing the page in a browser. 接著,您可以在瀏覽器中查看頁面來源,並將 CSS 區塊複製並貼到頁面標記中,或放在個別的檔案中。You can then view the page source in the browser and copy and paste the CSS block into the page markup or into a separate file.

如果您將此屬性設定為 false ,則無法設定樣式屬性。If you set this property to false, you cannot set style properties. 例如,您無法 DynamicHoverStyle-ForeColor 在標記中加入屬性,或在程式 DynamicHoverStyle.ForeColor 代碼中設定屬性。For example, you cannot add a DynamicHoverStyle-ForeColor attribute in markup or set the DynamicHoverStyle.ForeColor property in code.

適用於