ARTICLE

Developing Websites using Themes (Themes in Web Configuration File): Part 6

Posted by Abhimanyu Kumar Vatsa Articles | ASP.NET using VB.NET August 15, 2010
This is my series of articles on Theme based web developments and in this article part we will discuss how to register Themes in Web.config file and how to eliminate theme use from content page.
Reader Level:

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!
 

Login to add your contents and source code to this article
share this article :
post comment
 
Become a Sponsor
PREMIUM SPONSORS
  • Finally – a virtual platform that delivers next-generation Windows Server 2008 Hyper-V virtualization technology from a managed hosting partner you can truly depend on. Visit www.maximumasp.com/max for a FREE 30 day trial. Hurry offer ends soon. Climb aboard the MaxV platform and take advantage of High Availability, Intelligent Monitoring, Recurrent Backups, and Scalability – with no hassle or hidden fees. As a managed hosting partner focused solely on Microsoft technologies since 2000, MaximumASP is uniquely qualified to provide the superior support that our business is built on. Unparalleled expertise with Microsoft technologies lead to working directly with Microsoft as first to offer IIS 7 and SQL 2008 betas in a hosted environment; partnering in the Go Live Program for Hyper-V; and product co-launches built on WS 2008 with Hyper-V technology.
    The leading .NET charting control now features PDF, Flash and Silverlight export, visualization of large datasets and more. Deliver true charting functionality to your BI, Scorecard, Presentation or Scientific apps. Download evaluation now.
6 Months Free & No Setup Fees ASP.NET Hosting!
Become a Sponsor