Registering Themes in the Web Configuration File in ASP.Net

Rather than add the Theme or StyleSheetTheme attribute to each and every page to which you want to apply a Theme, you can register a Theme for all pages in your application in the web configuration file.

Web.Config

<configuration>
<system.web>
<pages theme="MySiteTheme" />
</system.web>
</configuration>

Rather than use the theme attribute, you can use the styleSheetTheme attribute to apply a Theme to the pages in an application. If you use the styleSheetTheme attribute, you can override particular Skin properties in a page.

Web.Config

<configuration>
<system.web>
<pages styleSheetTheme="MySiteTheme" />
</system.web>
</configuration>

After you enable a Theme for an application, you can disable the Theme for a particular page by using the EnableTheming attribute with the <%@ Page %> directive.

<%@ Page Language="C#" EnableTheming="false" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Disable Page Theme</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Label id="lblThemeMsg" Text="Don’t Use Theme : MySiteTheme !" Runat="server" />
</div>
</form>
</body>
</html>
Tags: ,
Hot on Web:


About author