Developing Websites using Themes (Adding CSS to Themes): Part 7

Introduction

We have lots of choices to work with Themes management. Rather than add the Theme or StyleSheetTheme attribute to each and every page to which we want to apply a Theme, we can register a Theme for all pages in your application in the web configuration file.

The Web.Config file given below applies the Site Theme to every page in an application.

Web.config Code

<?xml version="1.0"?>
<!--
  For more information on how to configure your ASP.NET application, please visit
  http://go.microsoft.com/fwlink/?LinkId=169433
 
-->
<
configuration>
       <
system.web>
              <
compilation debug="true" strict="false" explicit="true" targetFramework="4.0"/>

    <pages theme="Simple" />
    <!--or
    <pages styleSheetTheme="Simple" />
   
-->
  </
system.web>
</
configuration>

In above configuration file I have used <page theme="Simple" />, we also can use <pages styleSheetTheme="Simple" />. This tag helps to apply the theme in entire pages. The code given below has even no <%@ Page Language="VB" Theme="Simple" %> underlined tag but theme will work that is only because of configuration settings.

Default.aspx Code

<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="_Default" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<
body>
    <form id="form1" runat="server">
    <div>

    <asp:Calendar
        id="Calendar1"
        Runat="server" />

    </div>
    </form>
</body>
</
html>

The page given below has the EnableTheming="false" in head declaration so this page will not use the configuration theme settings.

Default2.aspx Code

<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default2.aspx.vb" Inherits="Default2" EnableTheming="false"%>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<
body>
    <form id="form1" runat="server">
    <div>

    <asp:Calendar
        id="Calendar1"
        Runat="server" />

    </div>
    </form>
</body>
</
html>

Note: Continue in next part.

HAVE A GREAT CODING!


Similar Articles