首页 > 代码库 > asp.net后台添加css、 js 、 meta、ascx

asp.net后台添加css、 js 、 meta、ascx

 1 //标题
 2 Title = "标题";
 3 //关键词
 4 HtmlMeta meta1 = new HtmlMeta();
 5 meta1.Name = "keywords";
 6 meta1.Content = "关键词";
 7 this.Page.Header.Controls.Add(meta1);
 8 //描述
 9 HtmlMeta meta2 = new HtmlMeta();
10 meta2.Name = "description";
11 meta2.Content = "描述";
12 this.Page.Header.Controls.Add(meta2);
13 //调用JS
14 HtmlGenericControl myJs = new HtmlGenericControl();
15 myJs.TagName = "script";
16 myJs.Attributes.Add("id", "pbjs");
17 myJs.Attributes.Add("type", "text/javascript");
18 myJs.Attributes.Add("data", "index");
19 myJs.Attributes.Add("src", ResolveUrl(Page.ResolveClientUrl("material/js/public.js")));
20 this.Page.Header.Controls.AddAt(1, myJs);
21 //调用ascx
22 Control uc = Page.LoadControl("index/index.ascx");
23 en1.Controls.Add(uc);