ASP web control and HTML


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
 
Ad

Advertisements

B

Brian Cryer

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.
 
Ad

Advertisements

C

Cubaman

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top