Home | HTML | Asp.Net | HTML Probe | .Net Probe
   
 www.solvingera.com 
  Contact Us |Sitemap
  

Themes in Asp.Net

Skip Navigation LinksHome>Asp Home>Themes

Themes are similar to Cascading Style Sheets (CSS) in that they enable you to define visual styles for your Web pages. A theme is used in web application by creating a skin file and attaching it to the web pages on which you want to apply the theme. Skin files are the file which is used to define the property setting for web server control. You can apply ASP.NET themes at the application, page, or server control level. Skin files are created and stored in a theme folder which is placed inside the App_Themes folder.

Some important feature of theme:

  • Themes are control-based, not HTML-based As a result, themes allow you to define and reuse almost any control property.

  • Themes are applied on the server side whereas a stylesheet is applies on the client side.

  • Themes can be applied through configuration files without modifying a single web page.

Creating a theme in Asp.Net

Follow these steps to create a theme:-
  • Select Website → Add New Items.

  • Select the Skin Files template under the Visual Studio templates dialog box.

  • Sets the name of the skin file in the Name text box.
  • Click the Add button.
  • A message box appears as shown below, Click the Yse button.
  • The App_Themes is added in the project and displayed in the Solution Explore window. The subfolder of this folder contains the skin file.
    Now Modify the skin file according to your designing recruitment.

Applying a Theme to a Single ASP.NET Page

You can apply a theme to a single page by adding the Theme attribute to the Page directive. It will change the appearance of the page as defined in the theme file.

Example Code Snippet:

<%@ Page Language="C#" Theme="ThemeFileName" %>

OR

To apply a theme at design time, you need to set the page.Theme property in your page code in the Page_PreInit event.

Applying a Theme to an Entire Application

To apply a theme at an application level, you need to configure the web.config file as an example code snippet given below…

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

This theme is applied automatically to each and every page within your application. You do not need to apply a theme in @Page directive.

Removing Themes from Server Controls

To remove a theme from a specific server control, sets the value of the EnableTheming property of that server control to False.

<asp:Textbox ID="txtname1" runat="server" BackColor="#00DDDD" ForeColor="#FF2D96" EnableTheming="false" />

Removing Themes from Web Pages

To remove a theme from a specific ASP.Net page, sets the value of the EnableTheming attribute of @ Page directive to False.

<%@ Page Language="C#" EnableTheming="False" %>

You can still enable theme for specific controls on this page by setting the Enable Theme property for the control to True .

<asp:Textbox ID="txtname1" runat="server" BackColor="#00DDDD" ForeColor="#FF2D96" EnableTheming="true" />
  
DMCA.com Protection Status
Design & Maintain By solvingera group| solvingera.com © 2013-2014 | all right reserved |Privacy Policy | Back to top