difference between htmlbutton and webcontrol button?

Discussion in 'ASP .Net' started by Bob, Mar 20, 2006.

  1. Bob

    Bob Guest

    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>
     
    Bob, Mar 20, 2006
    #1
    1. Advertisements

  2. Bob

    Teemu Keiski Guest

    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, Mar 20, 2006
    #2
    1. Advertisements

  3. Bob

    Bob Guest

    Thanks

     
    Bob, Mar 20, 2006
    #3
  4. Bob

    CMM Guest

    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."
     
    CMM, Mar 20, 2006
    #4
    1. Advertisements

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 (here). After that, you can post your question and our members will help you out.