Wednesday, August 7, 2013

ExecuteOrDelayUntilScriptLoaded does not work in SharePoint 2010

Hoi everyone.

It has been a very long time since I wrote a post about SharePoint. I was working on another small jQuery, KO project. Since it is nearing completion, I am back on track in SharePoint 2010.

We had a bug where all the script calls using ExecuteOrDelayUntilScriptLoaded doesn't get executed and was throwing exception SCRIPT5009: 'Type' is undefined which I had no idea of. After searching for some time, I came to know that for some reason MicrosoftAjax.js does not get loaded on all pages especially in Chrome browser. I came across this post and it seemed to be working for some time after adding reference to "/_layouts/MicrosoftAjax.js" on the master page. 


Make sure you add MicrosoftAjax.js reference before any instance of ScriptManager gets loaded in the page. Otherwise you will get a different error saying that Sys.WebForms.PageRequestManager is not defined.

There are other solutions as well like the one in the below link. you can give this also a try if it is applicable.

But, unfortunately then I got a different error on some other java script functions. I got the below error

Sys.ArgumentTypeException: Object of type 'Sys._Application' cannot be converted to type 'Sys._Application

Again did a search and found that it can be rectified by setting the ScriptManager's ScriptMode to "Release".

<asp:ScriptManager id="ScriptManager" runat="server" EnablePageMethods="false" ScriptMode="Release" />

Changing all the ScriptManager references in all the pages fixed the whole issue for now at least.

There are other solution that you can also

Hope this helps someone else or may for me itself sometime later.

Happy coding.
Senthil S

3 comments:

  1. Hello,
    I know this happens in SharePoint 2010 but what about Sharepoint 2013? I tried and this doesn't work.

    ReplyDelete
    Replies
    1. Haven't started on 2013 yet. Sorry pal.

      Delete
    2. in SP2013 I would use this instead:
      SP.SOD.executeFunc('sp.js', 'SP.ClientContext', myFunctionName);

      Delete