Page.ClientScript.RegisterClientScriptBlock,Page.ClientScript.RegisterStartupScript,Page.ClientScript.RegisterClientScriptInclude
Page.ClientScript.RegisterClientScriptBlock插入的脚本段是位于<form>标签之后,
Page.ClientScript.RegisterStartupScript 插入的脚本段位于</form>标签之后,
Page.ClientScript.RegisterClientScriptInclude是包含脚本代码
<!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>
Untitled Page
</title></head>
<body>
<form name="form1" method="post" action="Default.aspx" id="form1">
<div>
<input type="hidden" name="__VIEWSTATE" id="__VIEWSTATE" value="/wEPDwUKMTQ2OTkzNDMyMWRkPb6GgFXOTmMH39NwkaWsZM/zLR0=" />
</div>


<script type="text/javascript">
<!--
function AlertHello(){alert('hello World');}// added by RegisterClientScriptBlock-->
</script>

<script src="myjs.js" type="text/javascript"></script><!-- //added by RegisterClientScriptInclude-->
<div>
<input type="submit" name="button1" value="click" onclick="AlertHello();" id="button1" />
</div>
<div>

<input type="hidden" name="__EVENTVALIDATION" id="__EVENTVALIDATION" value="/wEWAgK//un9CwKs34rGBqVimdABq6wn3uyEbsMt/m15WTjj" />
</div>

<script type="text/javascript">
<!--
alert(document.forms[0]['TextBox1'].value);// added by RegisterStartupScript-->
</script>
</form>

</body>
</html>
Page.ClientScript.RegisterStartupScript 插入的脚本段位于</form>标签之后,
Page.ClientScript.RegisterClientScriptInclude是包含脚本代码
<!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>
Untitled Page
</title></head>
<body>
<form name="form1" method="post" action="Default.aspx" id="form1">
<div>
<input type="hidden" name="__VIEWSTATE" id="__VIEWSTATE" value="/wEPDwUKMTQ2OTkzNDMyMWRkPb6GgFXOTmMH39NwkaWsZM/zLR0=" />
</div>

<script type="text/javascript">
<!--
function AlertHello(){alert('hello World');}// added by RegisterClientScriptBlock-->
</script>
<script src="myjs.js" type="text/javascript"></script><!-- //added by RegisterClientScriptInclude-->
<div>
<input type="submit" name="button1" value="click" onclick="AlertHello();" id="button1" />
</div>
<div>
<input type="hidden" name="__EVENTVALIDATION" id="__EVENTVALIDATION" value="/wEWAgK//un9CwKs34rGBqVimdABq6wn3uyEbsMt/m15WTjj" />
</div>
<script type="text/javascript">
<!--
alert(document.forms[0]['TextBox1'].value);// added by RegisterStartupScript-->
</script>
</form>
</body>
</html>



浙公网安备 33010602011771号