我遇到了这样的问题,请教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);
或
Literal li = new Literal(); li.Text = " <script</script> " ; this .Page.Header.Controls.Add(li);
或者
Code