Why I can declare only one <page> in ASP.NET web.config file?
I'm new to ASP.NET 开发者_开发知识库and just start with Beginning ASP.NET 4 in C# and VB. I'm doing exercise on UserControl and I stuck in site-wide registration UserConrols that add registration syntax in web.config like below.
<pages theme="Monochrome">
<controls>
<add tagPrefix="Wrox" tagName="Banner" src="~/Controls/Banner.ascx" />
</controls>
</pages>
After I added this section to web.config everything work fine, since I have two themes in my website so I add new section for other theme.
<pages theme="DarkGrey">
<controls>
<add tagPrefix="Wrox" tagName="Banner" src="~/Controls/Banner.ascx" />
</controls>
</pages>
This time I can't compile my website, my user control doesn't show up at design-time. I want to know why I can't have two <page>
section?
The <pages>
node refers to all pages in your Website, so you can only have one of it. The theme
attribute sets the default theme for all your pages here. You don't have to register the control twice for different themes.
You can set different themes for different areas, but not the way you are trying to do it.
Read How to: Apply ASP.NET Themes:
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.
精彩评论