请教高手关于控制页面颜色的问题!

youzhadecandou 2009-12-24 05:44:02
怎样可以再aspx后台控制页面的颜色啊?
...全文
104 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
youzhadecandou 2009-12-24
  • 打赏
  • 举报
回复
多谢各位!
问题已经解决!
artwl_cn 2009-12-24
  • 打赏
  • 举报
回复
[Quote=引用 6 楼 mngzilin 的回复:]
html:

<bodyid="body1" runat="server">
    <form id="form1" runat="server">
        <divid="div1" runat="server"> </div>
    </form>
   
</body>

C# codeprotectedvoid Page_Load(object sender, EventArgs e)
{
div1.Attributes.Add("style","background-color:green;width:200px;height:200px;");
body1.Attributes.Add("style","background-color:red");
}
[/Quote]
顶!
mngzilin 2009-12-24
  • 打赏
  • 举报
回复
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");
}
wuyq11 2009-12-24
  • 打赏
  • 举报
回复
Page.Theme
document.body.bgColor
xiangziyanhuang 2009-12-24
  • 打赏
  • 举报
回复
backcolor啊.css也行的
十八道胡同 2009-12-24
  • 打赏
  • 举报
回复
改颜色:
.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";
}

62,254

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术交流专区
javascript云原生 企业社区
社区管理员
  • ASP.NET
  • .Net开发者社区
  • R小R
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

.NET 社区是一个围绕开源 .NET 的开放、热情、创新、包容的技术社区。社区致力于为广大 .NET 爱好者提供一个良好的知识共享、协同互助的 .NET 技术交流环境。我们尊重不同意见,支持健康理性的辩论和互动,反对歧视和攻击。

希望和大家一起共同营造一个活跃、友好的社区氛围。

试试用AI创作助手写篇文章吧