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
属性值
一个值,该值指示 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. 默认值为 true。The 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. 在以下情况下,你通常会将此属性设置为 false :You 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.
在这两种情况下,您都可以 Menu 通过将属性设置为 true ,运行页面,然后在浏览器中查看页面,来获取该控件生成的默认 CSS 块的副本。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.