Friday, 21 December 2012

Adding Javascript Programmatically to a Webpage


Adding Javascript Programmatically to a Webpage


Add this code to the Page_Init Event handler:

    protected void Page_Init(object sender, EventArgs e)
    {
        HtmlGenericControl js = new HtmlGenericControl("script");
        js.Attributes["type"] = "text/javascript";
        js.Attributes["src"] = "jscript/formfunctions.js";
        Page.Header.Controls.Add(js);
    }

No comments:

Post a comment

Thank You for Your Comments. We will get back to you soon.

back to top