Saturday, July 3, 2010

Skin Files in Asp.net ( App_Themes) Easily apply style to Server Controls

To Customize server Controls , ie having different background image,fore-color,bold etc  it is hard to go to each control and set its properties or css class. Asp.net provide an easy way to manage this. By use if Skin files we are able to manage that.

Website->AddNewItem->SkinFile

Skin file will be added to the Project.Vs will automatically add that to App_Themes->SkinFiles->skin.skin.
To bring that skin file to our page go to Source view and  add



<%@ Page Language="C#" Theme="SkinFile" AutoEventWireup="true"  CodeFile="Default.aspx.cs" Inherits="_Default" %>  where SkinFile is the name of the skin file  you are adding.

Now Lets See the Structure of Skin File




The above Skin is for TextBox... note the Skinid="Browse" so that we can use that ID to get that Particular skin on Textbox

See the aspx page



     

Now  you can see that that particular Skin is applied to text box. Like this can apply any number of Skins to all server controls. We can also write diff SkinId in the same Skin Files.

The Folder Structure is mentioned Below








8 comments:

  1. Do we need explicitly set skin id of a control in aspx page? Mentioning <%@ Page Language="C#" Theme="SkinFile"..., automatically sets the skin id of controls... right?

    ReplyDelete
  2. 1 suggestion.. that marquee kill my eyes! Please remove it if possible..

    ReplyDelete
  3. ok i will remove that...

    koolllllllllll

    Skin Id is mentioned in the Skin File.. check the Skin file

    ReplyDelete
  4. My qn. is, do we need to set skin id for individual textbox in an aspx page or just mentioning the skin file reference in the source automatically set skin ids of all textboxes?

    ReplyDelete
  5. ya we need to mention Skin Id. if u want that skin for all text boxes remove skinID from skin file so that it will go to all Text Boxes

    ReplyDelete
  6. if u dontwant a particular text box in that case set property of that text box Applytheming="false"

    ReplyDelete