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:
- ﹤%@ Page Theme="OrangeTheme" %﹥
- ﹤html﹥
- ﹤head runat="server"﹥
- ﹤title﹥Orange Page﹤/title﹥
- ﹤/head﹥
- ﹤body﹥
- ﹤form id="form1" runat="server"﹥
- Enter your name:﹤br /﹥
- ﹤asp:TextBox ID="txtName" Runat="Server" /﹥
- ﹤br /﹥﹤br /﹥
- ﹤asp:Button ID="btnSubmit" Text="Submit Name" Runat="Server"/﹥
- ﹤/form﹥
- ﹤/body﹥
- ﹤/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.
- // By default, unspecified Skin defines the appearance of all TextBox types.
-
- <Asp: TextBox BackColor ="Orange"ForeColor ="DarkGreen"Runat ="Server"/>
-
- <Asp: Button BackColor ="Orange"ForeColor ="DarkGreen"Font-Bold ="True"Runat ="Server"/>
-
- // If you have named SkinID, you can define the appearance of the specified TextBox type.
-
- <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.
- ﹤configuration﹥
- ﹤system.web﹥
- ﹤pages theme="OrangeTheme" /﹥
- ﹤/system.web﹥
- ﹤/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:
- VoidPage_PreInit (ObjectSender, EventArgs e)
- {
- Page. Theme = Request ["ThemeName"];
-
- // If You Need to programmatically load the MasterPage file for the Page, you also need to define it here.
- This. MasterPageFile = Request ["MasterPageFile"];
- }
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.
- Application of ASP. NET code separation in website construction
- Analysis on ASP. NET code optimization
- Analysis on the use of CustomValidator, an ASP. NET data verification control
- Analysis of embedded code block application in ASP. NET web pages
- Analysis on SQL Server Database Backup Recovery in ASP. NET