// 引入js文件
HtmlGenericControl scriptControl = new HtmlGenericControl("script");
scriptControl.Attributes.Add("type", "text/javascript");
scriptControl.Attributes.Add("language", "JavaScript");
scriptControl.Attributes.Add("src", "../js/menu.js");
Page.Header.Controls.Add(scriptControl);
// 引入样式表
Literal cssControl = new Literal();
cssControl.Text = "<link href=/"../css/menu.css/" rel=/"stylesheet/" type=/"text/css/"/>";
Page.Header.Controls.Add(cssControl);
引入js还可以利用:
if (!Page.ClientScript.IsClientScriptIncludeRegistered("menu"))
Page.ClientScript.RegisterClientScriptInclude(this.GetType(), "menu",
Page.ResolveClientUrl(@"~/menu/menu.js"));
page类的东西蛮多的,呵呵~