adsense

Wednesday, October 24, 2012

Load javascript file via code behind

Sometimes the javacript file loaded in the header section seem to be unloaded during the page post backs. The trick is to register the file with ClientScriptManager  as follows.


protected void Page_Load(object sender, EventArgs e)
    {
        if(!this.Page.ClientScript.IsClientScriptIncludeRegistered("qry"))
            this.Page.ClientScript.RegisterClientScriptInclude("qry", ResolveClientUrl("~/js/YourScript.js"));
    }

Regards
Samitha

No comments:

Post a Comment