asp.net在Form顶部或底部执行js

在.aspx.cs文件中:
 
      //Form顶部
        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==" />
<script>alert('ww');</script>
    <div>
    ffffffffffffffff
    fffffffff
    </div>
   
   
<script>alert('aaaaa');</script>
</form>
   
</body>
</html>
posted @ 2008-04-30 17:00  一抹微蓝  阅读(344)  评论(0编辑  收藏  举报