Thursday 1 March 2012

How do you apply Themes to an entire application? || To apply a theme to a Web site in .NET



To apply a theme to a Web site
  1. In the application's Web.config file, set the <pages> element to the name of the theme, either a global theme or a page theme, as shown in the following example:
Eg: <configuration>
<system.web>
<pages theme=”BlueMoon” />
</system.web>
</configuration>

2. To set a theme as a style sheet theme and be subordinated to local control settings), set the styleSheetTheme attribute instead:
<configuration>
    <system.web>
        <pages styleSheetTheme="Themename" />
    </system.web>
</configuration>

3.The following examples show you how you can define a theme named "SmokeAndGlass" in your application by different methods:

<%@ Page Theme="SmokeAndGlass" Language="C#"%>

4.Themes can be set programmatically under the Page_PreInit event handler. It is necessary to define them in this event handler as all the looks are applied to the server controls defined in a particular theme before the page loads. Here is how you can set themes programmatically:

Protected Sub Page_PreInit(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.PreInit
        Page.Theme = "SmokeAndGlass"
 End Sub

No comments:

Post a Comment