Use skin skin file to implement a program skin change in VS 2005

Source: Internet
Author: User
Or as usual, write a little tutorial, hehe.

First run your VS 2005, create a new Web site project, and then you can start with the program skin.

This example is concerned with the following elements:

1, the establishment of Web Form file;
2, establish skin appearance document;
3, the establishment of database files;

First, drag and drop the two GridView control, a button control, and two link tags in your default.aspx file, and drag it back to the following diagram:


After drag, default.aspx file source code as follows:

1 <% @ Page language= "C #" autoeventwireup= "true" codefile= "Default.aspx.cs" inherits= "_default" theme= "Default"% >
2
3 <! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">
4
5 < HTML xmlns = "http://www.w3.org/1999/xhtml" >
6 < head runat = "server" >
7 < title > Untitled page </title >
8 9 < BODY style = "font-size:12px;" >
< form ID = "Form1" runat = "server" >
< div >
< Asp:hyperlink ID = "HyperLink1" runat = "server" NAVIGATEURL = "~/default.aspx?" Skin=default "> Default skin </asp:hyperlink >
< Asp:hyperlink ID = "HyperLink2" runat = "server" NAVIGATEURL = "~/default.aspx?" Skin=diy "> Personality skin </asp:hyperlink >< br/>
< br/>
< Asp:gridview ID = "GridView1" runat = "server" Height = "99px" Width = "254px" >
</Asp:gridview >
< br/>
18
</div >
< Asp:button ID = "Button1" runat = "server" Text = "button" Height = "40px" Width = "109px"/>
< br/>
< br/>
< Asp:gridview ID = "GridView2" runat = "server" Height = "91px" SkinID = "Gridviewskin" Width = "267px" &G T
</Asp:gridview >
</form >
</Body >
</HTML >


When you're done, on the VS menu, point to "website"--"Add New Item", add appearance file, file name is Default.skin, the development tool will automatically create a App_Themes folder, for instructions on this folder, please refer to MSDN.

The contents of the Default.skin file are as follows:
1 <%--
2//document name: Skin Skins
3//Author: Li Xiyuan
4//Date: 2006-12-01
5//Support website: http://www.popmis.com
6//Personal Blog: http://lixyvip.cnblogs.com
7--%>
8 < Asp:gridview runat = "server" BackColor = "Green" >
9 < AlternatingRowStyle BackColor = "Blue"/>
Ten </Asp:gridview >
11
< Asp:gridview runat = "server" SkinId = "Gridviewskin" BackColor = "#C0FFC0" >
< AlternatingRowStyle BackColor = "#C0C0FF"/>
</Asp:gridview >

Note: Here is a description, if you use theme in a page page, when defined in the skin, be aware of:

<asp:gridview runat= "Server" backcolor= "Green" >
and
<asp:gridview runat= "Server" skinid= "Gridviewskin" backcolor= "Green";
There are different meanings, one adds SkinId, one does not, All two sets the skin for the GridView in the page, but if you do not specify a definition for SkinID, it is for all GridView controls in the page, and if you specify a definition for SkinID, it refers to one of the GridView controls in the page. You need to pay attention here. (So, I'm going to drag two GridView in the WebForm page to illustrate this)

Then, create a skin Diy.skin file with the following file contents:
 1 <%

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.