1: using System;
2: using System.Collections.Generic;
3: using System.Linq;
4: using System.Web;
5: using System.Web.UI;
6: using System.Web.UI.WebControls;
7:
8: public partial class ClientScript : System.Web.UI.Page
9: {
10: protected void Page_Load(object sender, EventArgs e)
11: {
12: Response.Write("<script>alert('test1---直接Response输出')</script>");
13:
14: Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "", "<script>alert('test2')</script>");
15:
16: if (!ClientScript.IsClientScriptBlockRegistered(this.GetType(), "ClientScriptBlock"));
17: {
18: ClientScript.RegisterClientScriptBlock(this.GetType(), "ClientScriptBlock", "<script>alert('test3---靠近<form>先弹出')</script>");
19: }
20:
21: if (!ClientScript.IsStartupScriptRegistered(this.GetType(), "StartupScript"))
22: {
23: ClientScript.RegisterStartupScript(this.GetType(), "StartupScript", "<script>alert('test4---靠近</form>后弹出')</script>");
24: }
25:
26: }
27: }
可以通过查看页面源码,看看有什么不同…