An effective means of code duplication-skin

Source: Internet
Author: User

References:
Http://tech.sina.com.cn/s/2006-07-13/09071034998.shtml
Http://www.diybl.com/course/4_webprogram/asp.net/asp_netshl/2008224/101379_2.html

With the "themes and appearances" feature of ASP. NET 2.0, style and layout information can be divided into separate file groups, collectively referred to as "themes ". The topic can then be applied to any site, affecting the appearance of pages and controls on the site. In this way, you can easily change the style of the site by changing the topic, without editing the pages of the site. You can also share topics with other developers. The "theme and appearance" function of ASP. NET 2.0 can be used to easily control the beauty of the website.
Note:
After you click "add", the following dialog box is displayed. Figure 2 shows whether to add the topic file to the "App_Themes" folder. In the application, the topic file must be stored in the App_Themes folder in the root directory. The topic is composed of named subdirectories in the folder. This subdirectory contains one or more. A collection of appearance files with the skin extension. A topic can also contain subdirectories of CSS files and/or static files such as images. Click "yes" to add a topic named "Button" to the Web.

Skin Definition
Smart prompts without code in vs2008
Are there any code prompts in vs2010?

Create a skin file:

<% --
Default skin template. The following skins are provided as examples only.

1. Named control skin. The SkinId shocould be uniquely defined because
Duplicate SkinId's per control type are not allowed in the same theme.

<Asp: GridView runat = "server" SkinId = "gridviewSkin" BackColor = "White">
<AlternatingRowStyle BackColor = "Blue"/>
</Asp: GridView>

2. Default skin. The SkinId is not defined. Only one default
Control skin per control type is allowed in the same theme.

<Asp: Image runat = "server" ImageUrl = "~ /Images/image1.jpg "/>
-- %>
<Asp: Button runat = "server" BorderColor = "yellow" BackColor = "yellow" BorderStyle = "dotted"/>
<Asp: Button runat = "server" BorderColor = "blue" BackColor = "white" SkinID = "Blue"/>
<Asp: Button runat = "server" BorderColor = "red" BackColor = "red" Width = "150" BorderWidth = "2px" SkinID = "red"/>

 

Use skin

<% @ Page Language = "C #" AutoEventWireup = "true" Theme = "Button" CodeFile = "Default. aspx. cs" Inherits = "_ Default" %>

<! DOCTYPE html PUBLIC "-// W3C // dtd xhtml 1.0 Transitional // EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<Html xmlns = "http://www.w3.org/1999/xhtml">
<Head runat = "server">
<Title> </title>
</Head>
<Body>
<Form id = "form1" runat = "server">
<Div>

<Asp: Button ID = "Button1" runat = "server" Text = "Button"/>
& Nbsp; default skin button control <br/>
<Br/>
<Asp: Button ID = "Button2" runat = "server" Text = "Button" SkinID = "Blue"/>
& Nbsp; Name skin SkinID = & quot; Blue & quot; Button control <br/>
<Br/>
<Asp: Button ID = "Button3" runat = "server" Text = "Button" SkinID = "red"/>
& Nbsp; Name skin SkinID = & quot; red & quot; Button control <br/>
<Br/>
<Asp: Button ID = "Button4" runat = "server" Text = "Button" EnableTheming = "False"/>
& Nbsp; disable the Button control of the topic <br/>

</Div>
</Form>
</Body>
</Html>

 

Common page Jump practices
Use Response. Redirect

 

 

Related downloads:
Http://www.cnblogs.com/cleo/archive/2007/01/16/freetextbox3_1_6.html

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.