I,Create a topic
InApp_themesApplicationProgramTo create a topic. InApp_themesEach folder added in represents a topic.
Important file types in the topic folder include skin files andCSSFile.
II,Add skin to topic
A topic may contain one or more skin files. You can use the skin to modify all skin effects.ASP. NETControl Properties.
For exampleWebAll applicationsTextboxSet the background color of the control to yellow and selectDottedAs its border style. InApp_themesCreate a folderSimpleFolder, and thenSimpleCreate a folderTextbox. SkinFile.CodeAs follows:
<Asp: textbox backcolor = "yellow" borderstyle = "dotter" runat = "server"/>
Note the code above.RunatIs required and cannot containIDAttribute.
A topic folder can have one or hundreds of skin files, but all files in a topic folder are compiled into a topic class.
The topic folder aboveSimpleIf you want to use a topic defined by a page, use the following code:
<% @ Page Language = "C #" theme = "simple" %>
IfTextboxControl PropertiesEnablethemingSetFalse, The topic does not work.
1,Create named skin
When naming skin is defined, it is more than the default skin defined.SkinidProperty, specifySkinidThe property is defined by the named skinSkinidThe property name.
2. ThemesAndStylesheetthems
UseThemesWhen a topic is applied, the topic-defined skin overwrites the custom skin of the control on the page.
And useStylesheetthemsIf this parameter is specified, it will not be overwritten.
<% @ Page Language = "C #" stylesheetthems = "simple" %>
3,Disable skin
Each control containsEnablethemingProperty, setFalseThe topic skin is disabled.
4,InWebRegister a topic in the configuration file
<System. Web>
<Pages theme = "simple"/>
</System. Web>
After the topic in the program is enabled, you can use
<% @ Page Language = "C #" enabletheming = "false" %>
To disable a topic.
III,Add a topicCSS
In addition to topic skin, you can also useCSSTo control the pageHtmlElement andASP. NETControl skin. If you have addedCSSFile, the topic is automatically applied when the page is applied.CSS.
IV,Create a global topic
In this case, I have less applications. skip this step. For the knowledge that is rarely used and is not fundamental, my learning principle is to know this application. It is not too late to learn it when you have the opportunity to actually use it. Otherwise, you will never know where the technology is.
V,Dynamic Application skin
By processingPage_preinitEvents can dynamically apply themes on the page. This is the first event triggered on the request page. AfterPage_loadOrPage_prerenderThe topic cannot be dynamically applied to events.
<% @ Page Language = "C #" %>
<! Doctype HTML public "-// W3C // dtd xhtml 1.1 // en" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<SCRIPT runat = "server">
Protected void page_preinit (Object sender, eventargs E)
{
If (request ["theme"]! = NULL)
{
Switch (request ["theme"])
{
Case "green ":
Profile. usertheme = "greentheme ";
Break;
Case "pink ":
Profile. usertheme = "pinktheme ";
Break;
}
}
Theme = profile. usertheme;
}
</SCRIPT>
<HTML xmlns = "http://www.w3.org/1999/xhtml">
<Head runat = "server">
<Title> dynamic theme </title>
</Head>
<Body>
<Form ID = "form1" runat = "server">
<Div class = "content">
<H1> dynamic theme
Please select a theme:
<Ul>
<Li>
<A href = "dynamictheme. aspx? Theme = green "> green theme </a>
</LI>
<Li>
<A href = "dynamictheme. aspx? Theme = pink "> Pink theme </a>
</LI>
</Ul>
</Div>
</Form>
</Body>
</Html>
ThroughThemeProperties. A specific topic can be applied to this page. InPreinitThe topic name is assigned toThemeAttribute. The topic is applied to this page.
When you save the informationProfileThis information is retained when you browse multiple sites. Therefore, if you select a topic you like, the topic will still be applied when the user returns to the site again later.
InWeb. configFile DefinitionProfile
<System. Web>
<! --
<Pages theme = "simple3"/>
-->
<Profile>
<Properties>
<Add name = "usertheme"/>
</Properties>
</Profile>
</System. Web>