1. When theme is applied to a page, the default skin automatically applies to all controls of the same type on the page. What kind of skin is the default skin? The criterion is whether the skinid attribute exists. If not, the default skin is used.
2. A named skin has a skinid attribute. The naming skin does not apply to the control automatically through the type. You must explicitly apply a named skin by setting the skinid attribute of the control. Using Named skin allows you to set different skins for different instances of the same control.
3. global theme settings: Set theme for all pages and add the following tag in the <system. Web> section of Web. config: <pages stylesheettheme = "datawebcontrols"/>
4. Set theme on a single page. Use @ page to set theme or stylesheettheme attributes on the page.
5.
Theme Property, the control settings in theme and the page settings on the page will
Merge The final setting of the control. If a control property is set on the page and theme, the control settings in theme overwrite the control settings on the page. This policy allows the pages to maintain a consistent style. For example, it allows you to apply theme to your asp.. NET page. in addition, you can apply theme to the page as a style sheet, by setting
Stylesheettheme Attribute. In this case,
Local page settings take precedence over theme settings . This is a model that uses a stacked style sheet. If you want to set a single control attribute and apply theme to control the overall performance, you can apply theme as a style sheet.
6. Dynamic Setting The code for global. asax is as follows:
<% @ApplicationLanguage = " C # " %>
< ScriptRunat = " Server " >
Void Page_preinit ( Object Sender,Brockallen. Web. pageeventargsE)
{
String T = Httpcontext. Current. profile. getpropertyvalue ( " Theme " ) As String ;
If (T ! = Null && T. Length > 0 )
{
E. Page. Theme= T;
}
Else
{
E. Page. Theme= "Default";
}
}
7. Read pages nodes in Web. configSystem. Web. configuration. pagessectionPS= (System. Web. configuration. pagessection) system. configuration. configurationmanager. getsection ("System. Web/pages");
Textbox1.text= PS. theme;
In ASP. before the emergence of NET 2.0, It was a heavy task to provide the theme change function for the website, you must change the corresponding pictures, fonts, webpage styles, and other small elements on the page.CodeIn addition to writing, standard management of resources is required. In the early stages of website preparation, if you do not have some experience, it is difficult to fully consider the detailed classification and placement of resource files. This eventually leads to a large number of migration and changes during the website revision process, which may cause file loss.
All these concerns have been well resolved in ASP. NET 2.0. First, you can implement complex functions through simple code writing. Second, Asp. NET 2.0 provides a clear directory structure when dealing with theme issues, so that the hierarchical relationship between resource files is very clear, while easy to find and manage, it also provides good scalability.
Next let's use a demo to learn about the new features of ASP. NET 2.0.
1. Create a topic Folder:
In the ApplicationProgramRight-click the root directory of, and click the theme folder option under add folder. An empty folder named app_themes will appear in the root directory, all resource files related to topics are stored in this folder.
In this example, select different colors to differentiate themes. You need to create two folders named by color in the theme folder (app_themes.
Operation Method: Right-click the app_themes folder and move the mouse to the Add folder option. It is found that there is only one type of theme folder added to the topic folder (app_themes:
Create two theme folders named bluetheme and porpletheme respectively.
Apply the theme bluetheme to the page:
<% @ Page Language = "C #" stylesheettheme = "bluetheme" %> |
3. Add the skin file to each topic separately:
The skin file actually contains the format settings applied to the topic. A topic can contain one or more skin files. This does not matter, because when a topic is applied to a page, ASP. NET Framework combines multiple skin files under a topic and treats these files as a skin file.
You can name the skin file as needed. In the file, you can set one or more properties in the control by declaring an instance of a control, in this way, the skin file is used to specify the control appearance. (Note: not all attributes can be set. Most attributes can be set as appearance attributes ).
In this example, a new control. Skin file is created in the theme bluetheme, and some attributes of the three controls are set in the file.
<ASP:Textbox Backcolor= "# C4d4e0" Forecolor= "#0b12c6" Runat= "Server" /> <ASP:Label Forecolor= "#0b12c6" Runat= "Server" /> <ASP:Button Backcolor= "# C4d4e0" Forecolor= "#0b12c6" Runat= "Server" /> |
The page code is as follows:
<Body> <Form ID = "form1" runat = "server"> <Table width = "100%" cellpadding = "0" cellspacing = "0" border = "0"> <Tr> <TD Height = "23px" colspan = "2"> </TD> </Tr> <Tr> <TD align = "center" Height = "50px"> <Asp: Label id = "label1" runat = "server" text = "enter your name:"> </ASP: Label> </TD> <TD> <Asp: textbox id = "textbox2" runat = "server"> </ASP: textbox> </TD> </Tr> <Tr> <TD align = "center" Height = "50px"> <Asp: Label id = "label2" runat = "server" text = "Enter your nickname:"> </ASP: Label> </TD> <TD> <Asp: textbox id = "textbox1" runat = "server"> </ASP: textbox> </TD> </Tr> <Tr> <TD align = "center" Height = "50px"> <Asp: button id = "button1" runat = "server" text = "OK"/> </TD> <TD> <Asp: button id = "button2" runat = "server" text = "cancel"/> </TD> </Tr> <Tr> <TD Height = "23px" colspan = "2"> </TD> </Tr> |