Benefit of useing UseSubmitBehavior in asp.net button?
Gets or sets a value indicating whether the Button control uses the client browser's submit mechanism or the ASP.NET postback mechanism.
Use the UseSubmitBehavior property to specify whether a Button control uses the client browser's submit mechanism or the ASP.NET postback mechanism. By default the value of this property is true, causing the Button control to use the browser's submit mechanism. If you specify false, the ASP.NET page framework adds client-side script to the page to post the form to the server.
When the UseSubmitBehavior property is false, control developers can use the GetPostBackEventReference method to return the client postback event for the Button. The string returned by the GetPostBackEventReference method contains the text of the client-side function call and can be inserted into a client-side event handler.
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.