怎样可以再aspx后台控制页面的颜色啊?

解决方案 »

  1.   

    改颜色:
    .aspx :
    <%@ Page Language="C#" AutoEventWireup="true" CodeFile="SessionTest.aspx.cs" Inherits="SessionTest" %><!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>
        <link rel="Stylesheet" href="test.css" type="text/css"/>
        <script type="text/javascript">
        function ChangeColor()
        {
            document.body.bgColor = "<%=bgcolor%>";
        }
        </script>
    </head>
    <body onload="ChangeColor()">
        <form id="form1" runat="server">
        <div>
            <asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Button" />
           <asp:Button ID="Button2" runat="server" Text="Button" />
            </div>
        </form>
    </body>
    </html>.aspx.cs 里
    using System;
    using System.Data;
    using System.Configuration;
    using System.Collections;
    using System.Web;
    using System.Web.Security;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using System.Web.UI.WebControls.WebParts;
    using System.Web.UI.HtmlControls;
    using System.Runtime.InteropServices;public partial class SessionTest : System.Web.UI.Page
    {
        protected string bgcolor;    protected void Page_Load(object sender, EventArgs e)
        {    }    protected void Button1_Click(object sender, EventArgs e)
        {
            bgcolor = "red";
        }
      

  2.   

    http://blog.csdn.net/xianfajushi/archive/2009/10/29/4745120.aspx
      

  3.   

    Page.Theme
    document.body.bgColor 
      

  4.   

    html:<body id="body1" runat="server">
        <form id="form1" runat="server">
            <div id="div1" runat="server"></div>
        </form>
        
    </body>   protected void Page_Load(object sender, EventArgs e)
        {
            div1.Attributes.Add("style","background-color:green;width:200px;height:200px;");
            body1.Attributes.Add("style","background-color:red");
        }