Popular Posts ! Traffic without Google Ι All in One SEO TacticsΙ Why Adsense Rocks


Saturday, March 9, 2013

How to apply ASP.Net Skin and Theme for better Web Designing


In one of my previous blog I had mentioned Theme property of page directive. In this blog we are going to discuss various ways we can apply asp.net skin in a website.
There are various ways to apply a particular Theme. This can be done:
  1. On Page Level
  2. On Website Level and
  3. Dynamically on Page Level(from cookies or from database, based on user preferences)

Page Level

Theme can be applied on page level by setting Theme attribute of Page directive in markup file. For example:
<%@ Page Language="C#" AutoEventWireup="true" StyleSheetTheme="ThemeName" %>
Where ThemeName is the name of any theme which you want to set as the current theme for the page.
Website Level:
You can also set theme for overall website from web.config file. The element is shown below:
<configuration>    <system.web>      <pages theme="ThemeName">        ...      </pages>    </system.web>  </configuration>
This theme will take effect on all the pages of current website.

Setting Theme Dynamically from Code

It's not always the case that we set theme name while launching our website for the first time for entire website or a web page. There are cases when individual users are given option to set their preferences based on their own choice. They can thus select any theme to be applied for them. These preferences can be saved on user machine by saving a value in cookies or this can be done on database server and thus the preferences details can be accessed and maintained globally. These settings will be applied no matter from where the user is accessing the web application.
You can load this theme dynamically on Page_PreInit event of the page. Have a look at the code snippet below:
protected void Page_PreInit(object sender, EventArgs e) {  Theme = "ThemeName"; // can be taken from cookies or session or database dynamically }
So you can use any one of the above three methods to apply theme on page level or overall website level depending on your requirements and needs.

ASP.Net, Web Designing

0 comments:

Post a Comment

 
© Technosati.com – All Rights Reserved

About Us | Privacy Policy | Write For Us