Analysis of Theme functions in ASP. NET development skills

Source: Internet
Author: User

What are the main Theme functions of ASP. NET development skills? Next let's take a look:

The Theme feature is added in ASP. NET 2.0, which makes it easier for websites to skin over.

Theme implementation includes: CSS, Skin, and MasterPage.

CSS is used to control the appearance of all HTML tags.

Skin is used to control the appearance of all ASP. NET servers, and its CSS style can be defined through the cssClass attribute.

MasterPage is a *. aspx page template, but it is not defined in Theme.

◆ ASP. NET development tips:

1. Create the App_Themes directory in the Web project. It is a predefined directory. ASP. NET 2.0 automatically recognizes Theme under its directory.

2. Create orangeTheme and BlueTheme subdirectories in the App_Themes directory.

3. Add a Skin file for each subdirectory under App_Themes, such as Control. Skin. ASP. NET 2.0 automatically analyzes each Skin file. The name here only needs to be easily classified during development.

4. You can also add a CSS file for each subdirectory under App_Themes. ASP. NET 2.0 automatically adds each CSS file to each page that uses this style.

◆ ASP. NET development skills-page content definition and ASP. NET Theme Style

1. The default. aspx page is defined as follows:

 
 
  1. ﹤%@ Page Theme="OrangeTheme" %﹥  
  2. ﹤html﹥  
  3. ﹤head runat="server"﹥  
  4. ﹤title﹥Orange Page﹤/title﹥  
  5. ﹤/head﹥  
  6. ﹤body﹥  
  7. ﹤form id="form1" runat="server"﹥  
  8. Enter your name:﹤br /﹥  
  9. ﹤asp:TextBox ID="txtName" Runat="Server" /﹥  
  10. ﹤br /﹥﹤br /﹥  
  11. ﹤asp:Button ID="btnSubmit" Text="Submit Name" Runat="Server"/﹥  
  12. ﹤/form﹥  
  13. ﹤/body﹥  
  14. ﹤/html﹥ 

2. The Control. Skin file on the OrangeTheme homepage is defined as follows:

Note: Only appearance attributes can be specified, and attributes such as AutoPastback cannot be specified.

 
 
  1. // By default, unspecified Skin defines the appearance of all TextBox types. 
  2.  
  3. <Asp: TextBox BackColor ="Orange"ForeColor ="DarkGreen"Runat ="Server"/>
  4.  
  5. <Asp: Button BackColor ="Orange"ForeColor ="DarkGreen"Font-Bold ="True"Runat ="Server"/>
  6.  
  7. // If you have named SkinID, you can define the appearance of the specified TextBox type. 
  8.  
  9. <Asp: TextBox SkinID ="Title"BackColor ="Orange"ForeColor ="DarkGreen"Runat ="Server"/>

◆ ASP. NET development skills-use ASP. NET Theme on the page

1. Add the Theme = "Default" attribute to the top of the Aspx file <% @ Page %>. In this way, you can use the Default topic.

2. If you want to apply a Theme to the entire website, you need to define it in Web. Config.

 
 
  1. ﹤configuration﹥  
  2.   ﹤system.web﹥  
  3.     ﹤pages theme="OrangeTheme" /﹥  
  4.   ﹤/system.web﹥  
  5. ﹤/configuration﹥ 

This definition is equivalent to a default Theme in all website files. during use, you can still define Theme for each page.

The Skin part uses the Theme defined in the Page, and CSS will reload the CSS style sheet on the default homepage.

3. After Theme is specified, all appearances are defined in Skin. You can also specify the SkinID of the control to define a separate appearance.

4. If you want to define Theme programmatically, it must be processed in the Page_PreInit event, as shown below:

 
 
  1. VoidPage_PreInit (ObjectSender, EventArgs e)
  2. {
  3. Page. Theme = Request ["ThemeName"];
  4.  
  5. // If You Need to programmatically load the MasterPage file for the Page, you also need to define it here. 
  6. This. MasterPageFile = Request ["MasterPageFile"];
  7. }

Understanding these technologies will make the website more changeable.

The basic usage of ASP. NET Theme in ASP. NET development skills will be introduced here.

  1. Application of ASP. NET code separation in website construction
  2. Analysis on ASP. NET code optimization
  3. Analysis on the use of CustomValidator, an ASP. NET data verification control
  4. Analysis of embedded code block application in ASP. NET web pages
  5. Analysis on SQL Server Database Backup Recovery in ASP. NET

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.