ASP web control and HTML

  • Thread starter Thread starter Tony Johansson
  • Start date Start date
T

Tony Johansson

Hello!

What is the difference if I use a ASP web control Button compared to if I
use a HTML Button.
Below is two example where the first row is using a ASP web control and the
second row is using HTML control.


<asp:Button ID="Button2" runat="server" Text="Button" />
input id="Button1" type="button" value="button" />

//Tony
 
Tony Johansson said:
Hello!

What is the difference if I use a ASP web control Button compared to if I
use a HTML Button.
Below is two example where the first row is using a ASP web control and
the second row is using HTML control.


<asp:Button ID="Button2" runat="server" Text="Button" />
input id="Button1" type="button" value="button" />

I'm assuing the missing opening bracket on the second button was a typo.

Probably the main difference between the two is that with the <asp:Button
....> the ASP.NET framework will do a lot of work for you. The framework will
detect if the button has been clicked and call the appropriate handler
(Button2_Click). You also have more control because you can refer to the
button in your code (Button2) and hide it, apply styles to it, change the
text, etc.

If you use a standard HTML control then the end HTML will be very similar,
but at the server you have to do the work to detect whether or not the
button has been clicked. You also loose the ability to change its attributes
in code.

As a rule I'd suggest always using the ASP.NET button.

Hope this helps.
 
I'm assuing the missing opening bracket on the second button was a typo.

Probably the main difference between the two is that with the <asp:Button
...> the ASP.NET framework will do a lot of work for you. The framework will
detect if the button has been clicked and call the appropriate handler
(Button2_Click). You also have more control because you can refer to the
button in your code (Button2) and hide it, apply styles to it, change the
text, etc.

If you use a standard HTML control then the end HTML will be very similar,
but at the server you have to do the work to detect whether or not the
button has been clicked. You also loose the ability to change its attributes
in code.

As a rule I'd suggest always using the ASP.NET button.

Hope this helps.

Hello:
I agree with your explanation, but if you are not going to use any of
the benefits of aspnet controls, it's better to use html one's and
release server resources that otherwise will be wasted.
Best regards.
 
Back
Top