My project has multiple themes with different colors.
I need to skin certain textboxes with a specific font/size/etc.[no color difference]
Currently, I add <asp:TextBox SkinID="skinned" runat="server".../>
to all .skin files under each theme.
Is there a way to put this textbox skin in one place, like a master skin?
views:
347answers:
2You will need to list it under each theme, but you only need to list one control definition per theme. If you want a skin to be the default behavior for a control, specify the definition without a SkinID property.
The lack of inheritance or cascading in the ASP.NET Themes implementation is an unfortunate limitation that doesn't receive a lot of attention. In scenarios where you wish to have a global skin available to all themes (without changing the control definition itself), you have two options:
Option #1: Use a VirtualPathProvider
(The downside of this is that you can't use it on precompiled websites without a reflection-based workaround.)
You can define a Global.skin file under a special Global theme where shared skins are kept; you will also create a placeholder Global.skin file under all other themes as well:
App_Themes
- Global
\Global.skin (primary)
- ThemeA
\Global.skin (empty placeholder)
- ThemeB
\Global.skin (empty placeholder)
In the VirtualPathProvider you would then re-route all requests for App_Themes\*\Global.skin to App_Themes\Global\Global.skin.
Option #2: Use a Post-Build Task
This is an amendment to the above solution that avoids the precompiled websites limitation; instead of doing the re-route at runtime, you can apply it post-build via an ms-build task that simply propagates Global\Global.skin to all other theme folders.
I've used both options successfully.