概述:
主题文件必须存储在根目录的App_Themes文件夹下(除全局主题外)。
Step1 新建一个网站,网站项目点击右键->添加->添加ASP.NET文件夹->主题,在App_Themes文件夹上单击鼠标右键,在弹出的快捷菜单上选择“添加ASP.NET文件夹->”主题"命令,创建主题名为TextBoxSkin的文件夹,在该文件夹下新建一个外观文件,名称为:TextBoxSkin.skin.
Step2 打开TextBoxSkin.skin文件,输入代码:
<asp:TextBox runat="server" Text="文本框外观" BackColor="Bisque" forecolor="yellow" /> <asp:TextBox runat="server" SkinId="textboxSkin" BackColor="#FFFFC0" BorderColor="Olive" />
Step3 新建一个窗体网页default.aspx,拖入两个TextBox控件,设置属性如下:
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox> <asp:TextBox ID="TextBox2" runat="server" SkinID="textboxSkin"></asp:TextBox>
Step4 在default.aspx的编译头部添加主题指令,如下:
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="default.aspx.cs" Inherits="WebApplication7._default" Theme="TextBoxSkin" %>