我遇到了这样的问题,请教google,结果大多数只是介绍那个注册js的几个函数,而这几个函数插入的js都在body里面,幸而在老外那里看到了这个代码,其实比较简单,但够有用
1 HtmlGenericControl Include2 = new HtmlGenericControl("script");
2 Include2.Attributes.Add("type", "text/javascript");
3 Include2.InnerHtml = "alert('JavaScript in Page Header');";
4 this.Page.Header.Controls.Add(Include2);
2 Include2.Attributes.Add("type", "text/javascript");
3 Include2.InnerHtml = "alert('JavaScript in Page Header');";
4 this.Page.Header.Controls.Add(Include2);
或
Literal li = new Literal();
li.Text = "<script</script>";
this.Page.Header.Controls.Add(li);
li.Text = "<script</script>";
this.Page.Header.Controls.Add(li);
或者
Code
欢迎加群互相学习,共同进步。QQ群:iOS: 58099570 | Android: 572064792 | Nodejs:329118122 做人要厚道,转载请注明出处!
本文转自张昺华-sky博客园博客,原文链接:http://www.cnblogs.com/sunshine-anycall/archive/2009/10/24/1589315.html,如需转载请自行联系原作者