6.2在主题中添加皮肤
在主题中添加皮肤
一个主题可以包含一个或多个皮肤文件。可以通过皮肤来修改所有具有皮肤效果的ASP.net控件的属性
在Web应用程序中所有的TextBox控件的背景设为黄色,dotted 为边框样式
Simple\TextBox.skin
<asp:TextBox BackColor="Yellow" BorderStyle="Dotted" Runat="Server"/>
建议:
皮肤文件名和待修改的控件名称一样,再加上皮肤的扩展名即可。
<%@ Page Language="C#" Theme="Simple" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><script runat="server"></script><html xmlns="http://www.w3.org/1999/xhtml"><head runat="server"> <title></title></head><body> <form id="form1" runat="server"> <div> <asp:TextBox runat="server" /> </div> </form></body></html>
<asp:TextBox SkinID="DashedTextBox" BorderStyle="Dashed" BorderWidth="5px" RunAt="Server"/><asp:TextBox BorderStyle="Double" BorderWidth="5px" Runat="Server"/>
<%@ Page Language="C#" Theme="Simple2" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><script runat="server"></script><html xmlns="http://www.w3.org/1999/xhtml"><head runat="server"> <title>Show Named Skin</title></head><body> <form id="form1" runat="server"> <div> <asp:TextBox ID="TextBox1" SkinID="DashedTextBox" runat="server"></asp:TextBox> <br /> <br /> <asp:TextBox ID="TextBox2" runat="server"></asp:TextBox> </div> </form></body></html>
<%@ Page Language="C#" Theme="Simple3" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><script runat="server"></script><html xmlns="http://www.w3.org/1999/xhtml"><head runat="server"> <title>Show Skin Theme</title></head><body> <form id="form1" runat="server"> <div> <asp:Label ID="Label1" runat="server" Text="What color background do I have?" BackColor="Red"></asp:Label> </div> </form></body></html>
<asp:Calendar BackColor="White" BorderColor="White" BorderWidth="1px" Font-Names="Verdana" Font-Size="9pt" ForeColor="Black" NextPreFormat="FullMonth" Width="400px" Runat="Server"> <SelectedDayStyle BackColor="#333399" ForeColor="white"/> <OtherMonthDayStyle ForeColor="#999999"/> <TodayDayStyle BackColor="#CCCCCC"/> <NextPrevStyle Font-Bold="True" Font-Size="8pt" ForeColor="#333333" VerticalAlign="Bottom"/> <DayHeaderStyle Font-Bold="True" Font-Size="8pt"/> <TitleStyle BackColor="White" BorderColor="Black" BorderWidth="4px" Font-Bold="True" Font-Size="12pt" ForeColor="#333399"/> </asp:Calendar>
<%@ Page Language="C#" Theme="Simple4" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><script runat="server"></script><html xmlns="http://www.w3.org/1999/xhtml"><head runat="server"> <title>Show EnableTheming</title></head><body> <form id="form1" runat="server"> <div> <asp:Calendar ID="Calendar1" runat="server"></asp:Calendar> <br /> <br /> <asp:Calendar ID="Calendar2" EnableTheming="false" runat="server"></asp:Calendar> </div> </form></body></html>