Difference between the types of buttons

What is the difference between the following components ?

<button type="button">Click Me!</button>
<asp:button ID="cmdAvancar" runat="server" >Click Me!</asp:button>
<input type="submit" value="Submit">

I say for example in properties, event question, manipulation, click effects.

For example if I need to use the onsubmit Javascript event will all 3 work?

Author: LINQ, 2017-02-09

2 answers

  • <input type="button" /> is the primitive DOM type of the interface. In HTML5 it was replaced by the element HTMLButtonElement.
  • <button></button>, or HTMLButtonElement, is the HTML5 version. It can be of the type button, reset or submit.
  • <input type="submit" /> (and its sibling reset) are derivations of the element button. Certain behaviors are associated by default:
    • <input type="submit" /> sends the form under whose context the element exists;
    • <input type="reset" /> returns the fields present for their values original.
  • <asp:button> is not an HTML element. It is an abstraction of the platform ASP.NET to allow integration between the client- and server-side environments. The renderer generates an element <input type="button" />, but when this is clicked a javascript event is intercepted and a call is submitted to the application, which results in the invocation of the linked server-side event.
 7
Author: OnoSendai, 2017-02-09 18:42:00

The Button (asp:button) will be rendered in HTML as <input type="submit"> or as <button>. This will depend on the properties set.


This:

<asp:button ID="cmdAvancar" runat="server" >Click Me!</asp:button>

Will be rendered like this:

<input name="cmdAvancar" type="submit" value="Click Me" />

This

<asp:button ID="cmdAvancar" runat="server" UseSubmitBehavior=false >Click Me!</asp:button>

Will be rendered like this:

<button name="cmdAvancar" type="button">Click Me!</button>

In Button (asp:button) you can use the OnClientClick property to program onclick (JavaScript). You also have the OnClick event so that when clicked a Code-Behind event is executed.

 4
Author: , 2017-02-09 18:36:04