I need to run a specific javascript function only when the page is submitted using ajax.
I’ve tried the following:
ScriptManager.RegisterOnSubmitStatement(Page, Page.GetType(),
"scriptName", "MyFunction();");
But it seems to run during normal post-backs as well. I’ve also tried replacing the Page object with the UpdatePanel control but without any difference.
Is it perhaps possible inside the javascript function MyFunction() to detect if it is an ajax or normal submit?
This code solved the problem. Thanks to @user1341446 for pointing me in the right direction.
Register the javascript function on submit:
Inside the function detect if ajax submit: