Add js and css from codebehind


/ Published in: C#
Save to your folder(s)



Copy this code and paste it in your HTML
  1. HtmlHead head = (HtmlHead)Page.Header;
  2. HtmlLink link = new HtmlLink();
  3. link.Attributes.Add("href", Page.ResolveClientUrl("~/css/your sheet.css"));
  4. link.Attributes.Add("type", "text/css");
  5. link.Attributes.Add("rel", "stylesheet");
  6. head.Controls.Add(link);
  7.  
  8. Page.ClientScript.RegisterClientScriptInclude("jsname", Page.ResolveUrl("~/javascript/yourjs.js"));

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.