In this article I have told you that how to append javascript link under the head section. HTMLGenericControl is server control which provide html control tags which are <body>, <head>, <div>,<p>,<li> elements etc.
Here's is the solution
protected void Page_Load(object sender, EventArgs e)
{
HtmlGenericControl JSFile = new HtmlGenericControl();
JSFile.TagName = "script";
JSFile.Attributes.Add("type", "text/javascript");
JSFile.Attributes.Add("language", "javascript");
JSFile.Attributes.Add("src", ResolveUrl("Scripts/script.js"));
this.Page.Header.Controls.Add(JSFile);
}
Note: Add “System.Web.UI.HtmlControls” namespace to load HtmlGenericControl class
Output

Download
JSFile.zip (137.85 kb)
See live demo