I have a SharePoint app that is configured correctly in the web.config
for ASP.NET AJAX, but when I try to use the Sys class it says it's undefined. I have installed SP2 and know that AJAX is enabled because update panels work correctly. ScriptManager is being loaded to the page. I have a script link to register the external JS file and have confirmed that the URL is correct. But I am using _spBodyOnLoadFunctionNames.push(functionName())
to call the function that throws the error. Any help on this is greatly appreciated since all I come up with on google is how to integrate AJAX into ShareP开发者_运维百科oint.
JavaScript
_spBodyOnLoadFunctionNames.push(InitializeDynamicLoadingPanel());
function InitializeDynamicLoadingPanel() {
modalLayerID = '';
prm = Sys.WebForms.PageRequestManager.getInstance();
IsAsyncPostBack = prm.get_isInAsyncPostBack();
if (!IsAsyncPostBack) {
prm.add_initializeRequest(InitializeRequestHandler);
prm.add_beginRequest(BeginRequestHandler);
prm.add_pageLoading(PageLoadingHandler);
prm.add_pageLoaded(PageLoadedHandler);
prm.add_endRequest(EndRequestHandler);
}
}
C#
ScriptLink.Register(page, "dynamicLoadingPanel.js", false);
Change the first line to:
_spBodyOnLoadFunctionNames.push("InitializeDynamicLoadingPanel");
Your current code is basically telling it to push the result of the InitializeDynamicLoadingPanel function, which is forcing the function to execute immediately, before the ScriptManager scripts have been embedded.
精彩评论