I need to register a javascript file from code-behind. I am interested to know whether this just needs to be called at the initial page load, or do I have to call it on each postback too ?
string clientUrl = ResolveClientUrl('~/Includes/global.js'); if (!Page.ClientScript.IsClientScriptIncludeRegistered(GetType(), 'Global')) Page.ClientScript.RegisterClientScriptInclude(GetType(), 'Global', clientUrl);
You should register it in all postbacks. Checking to see if it is registered already is not really necessary. It will only render one include with the name ‘Global’.