I have a large .aspx page, with multiple server controls. And, there is also a JavaScript file referenced by this .aspx page. I want to have a JavaScript function within this existing .js file, that will get called before any postback that happens to the server.
[note: I have seen another post that mention how to do this in JQuery ( How to capture submit event using jQuery in an ASP.NET application? ), but I would like that to be done through the existing JavaScript file, rather than using a new technology like JQuery]
[Edited] Solution of using OnSubmit handler will not work for me…because it will not get called for postbacks that get triggered by server controls.
You need something like this:
onsubmitevent will rise any time form is submitted. No matter how.More details about attaching events with JS: https://developer.mozilla.org/en-US/docs/DOM/element.addEventListener