62,268
社区成员
发帖
与我相关
我的任务
分享
#master_main{margin:0px auto; width:800px; color:Red; }
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="test.aspx.cs" Inherits="test" Theme="myskin" %>
<!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>
<script type="text/javascript">
function test()
{
alert('客户端点击没问题~');
}
</script>
</head>
<body>
<form id="form1" runat="server">
<div id="master_main">
<table style="border-right: #000099 1px solid; border-top: #000099 1px solid; border-left: #000099 1px solid; border-bottom: #000099 1px solid">
<tr>
<td style="width: 100px">
1</td>
<td style="width: 100px">
2</td>
<td style="width: 100px">
3</td>
</tr>
</table>
<asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Button" OnClientClick="test()"/>
</div>
</form>
</body>
</html>
[code=C#]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;
public partial class test : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
Response.Write("<script>alert('为何点击后CSS无效了?')</script>");
}
}
protected void Button1_Click(object sender, EventArgs e)
{
ClientScript.RegisterStartupScript(typeof(string),"js","alert('这样就不会无效了');",true);
}
Response.Write("<script>alert('为何点击后CSS无效了?');window.location.href='aa.aspx'</script>");//假设你的当前页面为aa.aspx