What is Theme?
Theme is a collection of control styles applied to webcontrols on website. It gives the common looks and feel to all webcontols in a simple way. Its allows to abstract the styles so that it can be reused. So from the software engg point of it satisfy the reusability and easy maintainance quality.
- Theme only works for WebControls
- MasterPage can not define Theme but Theme can be set in the content pages.
- Control style defined in Theme will override the control style define in a page.
- Doesnt work at Design Time but StyleSheetTheme works
- Its collection of .skin and .css files
- Themes doesnt apply to page or control if EnableTheming="false" declare on it.
- If themes applied dynamically (runtime) then it should be set in before Page_Preinit.
To apply a Theme to app user need to create a folder with name App_Themes under application root directory and then create a folder with the name of Theme within App_Themes folder.
For example if I want to create a Blue theme for my WebSite then folder structure will look like as shown in image.
<pages theme="Blue" />
</system.web>
{
Page.Theme = "Blue";
}
eg.
<asp:Label runat=server Text="ThemedLabel" BackColor="Red" /> (This is called default skin for label)
If the Theme containing above skin file is applied to a page then all the labels on a page will
be shown with Text="ThemedLabel" BackColor="Red"
If there is no skinid defined in the control defination then that its consider as a default skin for that control.
How to defind different Style(skin) for the same control?
Using SkinID different skin for a control is defined.
eg.
<asp:Label runat=server Text="ThemedLabel" BackColor="Red" /> - Default skin for Label
/> - BoldLabel skin for Label
So if Themed page contain a label without any SkinID then default skin will be applied to that
label and if there is any Label exists with SkinID="BoldLabel" then Label will be
shown with Text="ThemedLabel_WithSkinId" BackColor="Blue" Font-Bold="true"
Different ways to organize the theme folder contents.
organise your theme folder in different ways. All the skin files get merged before
theme is applied to page.
- Just one .skin file that contain all control skin definations.
- Create one .skin file for each control.
- Group same the SkinIDs in one .skin file
Is there a way to share Theme between different Apps?
\WINDOWS\Microsoft.NET\Framework\v2.0.xxxxx\ASP.NETClientFiles\Themes\Theme1
Application level Theme will override the Global theme. ie if Theme named Blue is defined at Global and Application level then application level Blue theme will be applied to the site.
No comments:
Post a Comment