ASP web control and HTML

Discussion in 'ASP .Net' started by Tony Johansson, Nov 22, 2010.

  1. 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, Nov 22, 2010
    #1
    1. Advertising

  2. Tony Johansson

    Brian Cryer Guest

    "Tony Johansson" <> wrote in message
    news:iceeti$uec$-september.org...
    > 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.
    --
    Brian Cryer
    http://www.cryer.co.uk/brian
    Brian Cryer, Nov 23, 2010
    #2
    1. Advertising

  3. Tony Johansson

    Cubaman Guest

    On Nov 23, 1:29 pm, "Brian Cryer" <> wrote:
    > "Tony Johansson" <> wrote in message
    >
    > news:iceeti$uec$-september.org...
    >
    > > 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.
    > --
    >  Brian Cryer
    >  http://www.cryer.co.uk/brian


    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.
    Cubaman, Nov 24, 2010
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Matthew Louden
    Replies:
    1
    Views:
    6,876
    Scott M.
    Oct 11, 2003
  2. Reny J Joseph Thuthikattu
    Replies:
    1
    Views:
    542
    =?Utf-8?B?UHJha2FzaC5ORVQ=?=
    Dec 30, 2004
  3. =?Utf-8?B?c2VyZ2UgY2FsZGVyYXJh?=

    Help on HTML server control vs HTML control

    =?Utf-8?B?c2VyZ2UgY2FsZGVyYXJh?=, Sep 15, 2005, in forum: ASP .Net
    Replies:
    5
    Views:
    2,128
    =?Utf-8?B?c2VyZ2UgY2FsZGVyYXJh?=
    Sep 15, 2005
  4. =?Utf-8?B?YW1qYWQ=?=

    HTML Control and ASP.Net control question

    =?Utf-8?B?YW1qYWQ=?=, Jun 19, 2006, in forum: ASP .Net
    Replies:
    1
    Views:
    341
    =?Utf-8?B?RGVtZXRyaQ==?=
    Jun 19, 2006
  5. Tony Johansson
    Replies:
    2
    Views:
    912
    Tony Johansson
    Dec 1, 2010
Loading...

Share This Page