在我的协会中。 NET指,Im试图以动态方式增加一个CSS参考(与客户的智能相匹配)。
My code renders to the browser correctly, but it doesn t load the CSS file. I have to put the link in my markup explicitly for the CSS file to load, but it won t load when in code behind
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
FileInfo fi = new FileInfo(Server.MapPath("~/Styles/Site.css"));
HtmlGenericControl link = new HtmlGenericControl("LINK");
link.Attributes.Add("rel", "stylesheet");
link.Attributes.Add("type", "text/css");
link.Attributes.Add("href", "~/Styles/Site.css?t=" + fi.CreationTime.Ticks.ToString());
Page.Header.Controls.Add(link);
}
}
This seems really simple. Not sure why it isn t working.
NOTE: The present the fileinfo points has no effect on the conduct. 它提供罚款,但不管拿到档案资料,都无着装。