当前位置:Gxlcms >
asp.net >
asp.net(C#) 动态添加非ASP的标准html控件(如添加Script标签)
asp.net(C#) 动态添加非ASP的标准html控件(如添加Script标签)
时间:2021-07-01 10:21:17
帮助过:10人阅读
代码如下:
HtmlGenericControl Include2 = new HtmlGenericControl("script");
Include2.Attributes.Add("type", "text/javascript");
Include2.InnerHtml = "alert('JavaScript in Page Header');";
this.Page.Header.Controls.Add(Include2);
或使用:
代码如下:
Literal li = new Literal();
li.Text = "<script...</script>";
this.Page.Header.Controls.Add(li);