200字范文,内容丰富有趣,生活中的好帮手!
200字范文 > Asp.Net头部动态加载css和js文件的方法

Asp.Net头部动态加载css和js文件的方法

时间:2019-12-22 17:32:18

相关推荐

Asp.Net头部动态加载css和js文件的方法

首先head标签上添加runat="server"。

protected void Page_Load(object sender, EventArgs e){HtmlGenericControl autoCompleteScript = new HtmlGenericControl("script");autoCompleteScript.Attributes.Add("type", "text/javascript");autoCompleteScript.Attributes.Add("src", "/js/autocomplete/jquery.autocomplete.js");Page.Header.Controls.Add(autoCompleteScript);HtmlLink autoCompleteCss = new HtmlLink();autoCompleteCss.Href = "/js/autocomplete/jquery.autocomplete.css";autoCompleteCss.Attributes.Add("rel", "stylesheet");autoCompleteCss.Attributes.Add("type", "text/css");Page.Header.Controls.Add(autoCompleteCss);}

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。