一个站点ASP.NET多重主题 [英] ASP.NET Multiple Themes in One Site
问题描述
我有一个App_Themes文件目录,也掌握了ASP.NET网页。
I have an App_Themes directory, and also Master pages for a ASP.NET website.
我可以使用2个不同的主题,基于母版页上?
Can I use 2 different themes based on the master page?
推荐答案
MSDN大约有一篇文章 ASP.NET母版页和主题
MSDN has an article about ASP.NET Master Pages And Themes
您不能直接申请一个ASP.NET
主题母版页。如果添加
主题属性的法师@
指令,该页面将引发
错误当它运行。
You cannot directly apply an ASP.NET theme to a master page. If you add a theme attribute to the @ Master directive, the page will raise an error when it runs.
然而,主题应用到掌握
在这种情况下网页:
However, themes are applied to master pages under these circumstances:
-
如果一个主题是在内容定义
页。母版页是在解析
内容页面的情况下,这样的
内容页面的主题应用到
母版页为好。
If a theme is defined in the content page. Master pages are resolved in the context of content pages, so the content page's theme is applied to the master page as well.
如果站点的整体构成
通过包括一个主题用主题
定义的页面元素
(ASP.NET设置架构)元素。
If the site as a whole is configured to use a theme by including a theme definition in the pages Element (ASP.NET Settings Schema) element.
In addition to the above you can see the section about Themes and Skins. You can change theme programmatically
从MSDN示例
protected void Page_PreInit(object sender, EventArgs e)
{
switch (Request.QueryString["theme"])
{
case "Blue":
Page.Theme = "BlueTheme";
break;
case "Pink":
Page.Theme = "PinkTheme";
break;
}
}
但你不能同时使用两个主题,没有任何意义。但是,您可以更改基于使用该母版的主题。
But you cannot use two themes at the same time, that does not make any sense. You could however change the theme based on which masterpage is used.
要回答您的评论你的问题,是的,你可以有不同的子文件夹不同的主题。这是从MSDN:
To answer your question in your comment, yes you can have different themes for different sub-folders. This is from MSDN:
在Web.config文件中的一个主题设置
适用于所有的ASP.NET网页
该应用程序。主题设置在
Web.config文件遵循正常
配置层次约定。
例如,一个主题应用到仅
部分页面上,你可以把
在文件夹中的网页与自己
Web.config文件或创建
在根Web.config文件中的元素
指定文件夹。有关详细信息,请参阅
配置特定文件和
子目录。
A theme setting in the Web.config file applies to all ASP.NET Web pages in that application. Theme settings in the Web.config file follow normal configuration hierarchy conventions. For example, to apply a theme to only a subset of pages, you can put the pages in a folder with their own Web.config file or create a element in the root Web.config file to specify a folder. For details, see Configuring Specific Files and Subdirectories.
这篇关于一个站点ASP.NET多重主题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!