stylesheettheme 与 theme 的区别(转载)

原文出處:http://www.cnblogs.com/china-liuyang/articles/1050162.html

stylesheettheme 与 theme 的区别

首先们建立一个外观文件.名为 text.skin 然后在里面写入.

text.skin
<asp:TextBox runat="server" width="80px" /> //设置 TextBox 的宽度为 80px

<asp:button runat="server" width="60px" /> //设置 Button 的宽度为 60px

然后在 hello.aspx 页面引入外观文件.我们用 stylesheettheme 来引入

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="hello.aspx.cs" Inherits="hello" StylesheetTheme="text.skin" %>

<!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:TextBox ID="txtTest" runat="server" Width="100px"></asp:TextBox> <!-- 把txtTest的长度固定为100px -->
        <asp:TextBox ID="txtTest1" runat="server"></asp:TextBox> <!-- 不给txtTest1设置长度 -->
        <asp:Button ID="btnTest" runat="server" Text="Button" /><!-- 不给btnTest设置长度 -->
        </asp:DropDownList>
    </div>
    </form>
</body>
</html>

 

      这样显示页面效果为: txtTest的最终宽度为 100px;  txtTest1 的长度为 80px; btnTest:的长度为 60px; 这就说明,在页面对控件进行固定大小设置,然后用 StylesheetTheme 属性进行引用外观文件.是不会改变控件自身的固定大小.

     如果引用外观文件属性换为 Theme ,那么页面所有的 TextBox 的宽度都将为 80px;(不管是否有固定大小) 同理所有Button控件的宽度都将为 60px;

原文地址:https://www.cnblogs.com/purplefox2008/p/1359705.html