Working with Themes in ASP.NET 2.0
page 2 of 10
by SANJIT SIL
Feedback
Average Rating: This article has not yet been rated.
Views (Total / Last 10 Days): 43114/ 42

Applying Themes

Applying Theme to a Page

A Theme is an attribute of the page class that we can set in various ways. Once the Theme is set, the page ensures that all of its controls will render according to the visual settings defined in the Theme. Listing 1 illustrates how to define a Theme to a page.

Listing 1

<% Page Language=“C#” Theme=”myTheme” %>

Applying Theme to an Entire Application

In addition to applying an ASP.NET 2.0 theme to our ASP.NET pages using the Theme attribute within the page directive, we can also apply it at an application level from the Web.config file. Then the Theme will be applied automatically to each and every page within the application. This is illustrated in Listing 2.

Listing 2

<configuration>
  <system.web>
    <pages theme=”myTheme”/>
  </system.web>
</configuration>

Applying Theme to all Applications in a Server

If we want to use a particular theme for all the web applications in the server, we can do the same. We can specify the theme that we want to use within the machine.config file. This is illustrated in Listing 3.

Listing 3

<pages buffer="true" enableSessionState="true"
       enableViewState="true" enableViewStateMac="true"
       autoEventWireup="true" validateRequest="true"
       enablePersonalization="false" theme=" myTheme " >
</pages>

Thus adding the Theme attribute to the pages node within the machine.config file is a great solution for the server having multiple applications using the same Theme. Setting a Theme in the machine.config file means that we do not need to use this theme separately for all the applications on the server. If we specify another Theme in the application's web.config file or in the Web page's Page directive, then settings that are set in the web.config file override settings that are in the machine.config file and settings that are placed in the Page directive override both settings in the machine.config and in the web.config files.


View Entire Article

User Comments

No comments posted yet.

Product Spotlight
Product Spotlight 





Community Advice: ASP | SQL | XML | Regular Expressions | Windows


©Copyright 1998-2024 ASPAlliance.com  |  Page Processed at 2024-03-28 1:29:44 PM  AspAlliance Recent Articles RSS Feed
About ASPAlliance | Newsgroups | Advertise | Authors | Email Lists | Feedback | Link To Us | Privacy | Search