ASP.net 2.0 website skin-changing process __.net

Source: Internet
Author: User

First, Introduction:

 

Use Themes we can easily change the style of controls and pages without having to modify our code and page files. Themes files are separately placed under 1 app_themes folders and are completely separate from your program.

 

second, how to use Themes and Skins :

 

Let's look at a very simple example:

 

App_themes/default/1.skin File Code :

 

<asp:label font-bold= "true" forecolor= "Red" runat= "Server"/>

  Default.aspx: File code:

 

<%@ Page language= "C #" theme= "default"%>

<! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">

 

can see us in Default.aspx and did not write how the control style the code, but run fetch to find label the words on it all turned to bold red, which is 1 one of the most basic Theme examples.

 

  App_Themes folder:

 

  App_Themes The folder is located in the root directory of the program, App_Themes the next must be Theme A subfolder of the name that can contain multiple . Skin and . CSS files. The following figure establishes 2 Theme, named default and DEFAULT2:

 

 

 

Use Themes

 

  1 , in 1 application in a page Theme:

 

If you want to be in a 1 application in a page Theme , directly in aspx modified in File <%@ Page theme= "..."%> , for example you want this page to apply DEFAULT2 Theme , setting <%@ Page theme= "DEFAULT2"%> just OK

 

  2 , on all pages apply the same 1 a Theme:

 

If you want to use the same on all pages Theme , in Web.config in the <system.web> add a sentence under the node <pages theme= "..."/>

 

  3 , let the control not apply Theme:

 

paragraph 1 in an example, we see 2 a Label the style has changed. , Which means . Skin The style in the file is all on the page Label it all worked. But sometimes we want some 1 labels to not apply . Skin in the style, then you just set Label of the enabletheming property is false when it's ready.

 

Maybe you want to be different. label show a different style, you just set label of the SkinID property is available, see the following example:

 

App_themes/default/1.skin

 

<asp:label runat= "Server" font-bold= "true" forecolor= "Red"/> <asp:label "server" runat= "Blue" Font-bold= "true" forecolor= "Blue"/>

deafult.aspx

 

<%@ Page language= "C #" theme= "default"%> <! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">

When you run it, you'll find 2 a label the style of display is different.

 

  4 , other methods:

 

It's been said before aspx File Header Use <%@ Page theme= "..."%> to use Theme , and using this method Theme in the style will cover you write in aspx the control properties in style . For example:

 

  App_themes/default/1.skin

 

<asp:label font-bold= "true" forecolor= "Red" runat= "Server"/>

  Default.aspx

 

<%@ Page language= "C #" theme= "default"%> <! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">

run the results that all the label of the ForeColor All for Red .

 

and use <%@ Page stylesheettheme= "..."%> Application Theme would not cover you in aspx attributes written in the file style :

 

Control Application style the order of the attributes is as follows:

 

  a , StyleSheetTheme the style of the quote

 

  b , code-defined control properties

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.