difference between htmlbutton and webcontrol button?

B

Bob

Hi,

I 'm starting asp.net and i saw two ways to make buttons. Which way to use?
Are the htmlbuttons in specific case better than webbuttons? Are there
advantages?
Thanks
Bob

htmlbutton:
<script runat="server">
Sub button1(Source As Object, e As EventArgs)
p1.InnerHtml="You clicked the blue button!"
End Sub
</script>

<form runat="server">
<button id="b1" OnServerClick="button1" runat="server">htmlbutton</button>
<p id="p1" runat="server" />
</form>

and webcontrol button.
<script runat="server">
Sub submit(Source As Object, e As EventArgs)
button1.Text="You clicked me!"
End Sub
</script>

<form runat="server">
<asp:Button id="button1" Text="Click me!" runat="server" OnClick="submit"/>
</form>
 
T

Teemu Keiski

Hi,

basically you can do same thing with the both in this case. Difference is
that HtmlButton represents an HTML control which has API following closely
the HTML API. While WebControl Button is more abstracted over what it's
rendered as. E.g WebControls are more abstractions over the presentation
layer while HTML controls are tightly coupled with it. WebControls can also
expose and do things which aren't possible to expose via HTML control API.

Here's also a few links
http://steveorr.net/FAQ/3in1.aspx#HTMLvsWeb

ASP.NET Web Server Controls Overview
http://msdn2.microsoft.com/en-us/library/zsyt68f1.aspx
 
B

Bob

Thanks

Teemu Keiski said:
Hi,

basically you can do same thing with the both in this case. Difference is
that HtmlButton represents an HTML control which has API following closely
the HTML API. While WebControl Button is more abstracted over what it's
rendered as. E.g WebControls are more abstractions over the presentation
layer while HTML controls are tightly coupled with it. WebControls can also
expose and do things which aren't possible to expose via HTML control API.

Here's also a few links
http://steveorr.net/FAQ/3in1.aspx#HTMLvsWeb

ASP.NET Web Server Controls Overview
http://msdn2.microsoft.com/en-us/library/zsyt68f1.aspx

--
Teemu Keiski
ASP.NET MVP, AspInsider
Finland, EU
http://blogs.aspadvice.com/joteke
 
C

CMM

Basically the way I see it... WebControls trigger postback events and are
easier to set-up and manipulate on the server site. HTMLControls are classic
old-school html elements that do everything on the client-side (though you
could always at a RunAt attribute to them and essentially turn them into a
"WebControl."
 

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

Members online

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,906
Latest member
SkinfixSkintag

Latest Threads

Top