在.aspx.cs文件中:
//Form顶部
Page.RegisterClientScriptBlock("my", "<script>alert('ww');</script>");
//Form底部
Page.RegisterStartupScript("my", "<script>alert('aaaaa');</script>");
Page.RegisterClientScriptBlock("my", "<script>alert('ww');</script>");
//Form底部
Page.RegisterStartupScript("my", "<script>alert('aaaaa');</script>");
页面生成的Html代码如下:
<!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><title>
无标题页
</title></head>
<body>
<form name="form1" method="post" action="Default5.aspx" id="form1">
<input type="hidden" name="__VIEWSTATE" id="__VIEWSTATE" value="/wEPDwUJNzgzNDMwNTMzZGS442UBw5FBEJXBtmCNHc/m4vA0qg==" />
<head><title>
无标题页
</title></head>
<body>
<form name="form1" method="post" action="Default5.aspx" id="form1">
<input type="hidden" name="__VIEWSTATE" id="__VIEWSTATE" value="/wEPDwUJNzgzNDMwNTMzZGS442UBw5FBEJXBtmCNHc/m4vA0qg==" />
<script>alert('ww');</script>
<div>
ffffffffffffffff
fffffffff
<div>
ffffffffffffffff
fffffffff
</div>
<script>alert('aaaaa');</script>
</form>
</body>
</html>
<script>alert('aaaaa');</script>
</form>
</body>
</html>