Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Benefit of using UseSubmitBehavior in asp.net button

What is the benefit of using UseSubmitBehavior in an asp.net button?

like image 984
Venom Avatar asked Sep 17 '10 10:09

Venom


2 Answers

It's lighter and less complicated. Without the behavior it's an onclick call to postback through JavaScript...but this is actually harder to deal with on the client when you want your own JavaScript.

For example if I'm adding an onsubmit handler to the <form> this is much easier/more straightforward when the natural <form> submit behavior from a type="submit" button is happening, it's also easier with any JS library, tying in your functions in the right order (when not set server-side, when it renders) is much easier when there is no client-side onclick interfering.

You can tie into event bubbling, the onsubmit, set onclick events yourself to prevent any default behavior, etc...just easier to deal with all around.

There are other facets as well, but making JavaScript manipulation tremendously simpler is a big one, for me atleast.

like image 153
Nick Craver Avatar answered Sep 17 '22 14:09

Nick Craver


You can also use it as a workaround to the freezing animation issue. If, for example, you pop up a progress dialog with an animated gif in it when the user click a Submit button, the gif will freeze if you use the normal behaviour. If you set UseSubmitBehavior=False, then the gif will not freeze.

There are various other hacky ways of addresses the freezing gif issue but at least this one is simple.

like image 36
Rezler Avatar answered Sep 18 '22 14:09

Rezler