Last Updated: February 25, 2016
·
2.461K
· petermorlion

ASP.NET and jQuery submit event

ASP.NET has the concept of postbacks (for example, for LinkButtons), that can be a problem if you want to subscribe to the submit event with jQuery:

$('form').submit(function() {});

With postbacks, there is no submit event. ASP.NET has a javascript method __doPostBack that handles the calls to the server. That's why I wrote a jQuery plugin (http://plugins.jquery.com/beforePostBack/) to subscribe to the (new) beforePostBack event:

$.beforePostBack(function() {});

The plugin can be found here: https://github.com/petermorlion/jquery.beforePostBack

Have a fresh tip? Share with Coderwall community!

Post
Post a tip
Did you know?

JavaScript on a page runs with the privileges of that origin. One altered library, tag manager, or snippet can read inputs, change what people see, and call your APIs as the user.

Security insights from Cside