Typically, .NET handles a post back event on a button, creating a type = "submit" button:
<input type="submit" Text="Delete" />
However, I recently came across a situation where .NET processes the message back by typing type = "button" and then adding a javaScript onClick event to execute "__doPostBack ()", so you end up with this:
<input type="button" onClick="__doPostBack(...);" />
The problem with this is an attempt to add confirmation messages to the client. So, with the second scenario, I get the following:
<input type="button" onClick="return confirm('Are you sure?'); __doPostBack(...);" Text="Delete" />
Of course, in the above script, postback will never happen.
What I wonder is why .net selects one script there another and is there a way to prevent the second?
thanks
source share