在asp.net 中如何在.aspx.cs的文件里写代码来改变页面的颜色
我现在页面上有一按钮,我想通过点击此按钮来改变页面的颜色,请问各位高手怎样写程序来实现。谢谢在.aspz.cs中写写代码,也就是在后台控制,我正在做一个在线问卷调查系统,...
我现在页面上有一按钮,我想通过点击此按钮来改变页面的颜色,请问各位高手怎样写程序来实现。谢谢
在.aspz.cs中写写代码,也就是在后台控制,
我正在做一个在线问卷调查系统,我不知道怎样把问卷(就像考试的试卷那样)调出来显示在页面上,供参于调查的人进行填写问卷 展开
在.aspz.cs中写写代码,也就是在后台控制,
我正在做一个在线问卷调查系统,我不知道怎样把问卷(就像考试的试卷那样)调出来显示在页面上,供参于调查的人进行填写问卷 展开
3个回答
展开全部
改颜色:
.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";
}
}
.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";
}
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询