AddJavaScript

public static void AddJavaScript(this Page page, string url)
{
    HtmlGenericControl js = new HtmlGenericControl("script");
    js.Attributes["type"] = "text/javascript";
    js.Attributes["src"] = url;
    page.Header.Controls.Add(js);
}
Example:
public partial class Default : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        this.AddJavaScript("jsFile.js");
    }
}

Description

Dynamically adds a javascript file (.js) to a page even if using master page.

Details

Double click on the code to select all.