Some question about web control and the old HTML control

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

  1. Hello!

    I'm trying to understand these two types of control which are the new web
    control and the old style HTML control that
    originated from the standard asp time.
    I hope to get an answer to these questions.

    1. This type
    <input id="Submit1" runat="server" type="submit" value="submit"
    onclick="return Submit1_onclick()" />
    is the old HTML control. When I click this button event handler
    Submit1_onclick() is executed. But where is it executed is it on the server
    or on the Client ?
    The strange thing here is that when I click the submit button the Page_Load
    on the server is called. whch means that this cause a postback.

    2. Does it matter if I have runat="server" included or not when I use the
    old HTML control.?

    3. Is it possible to say that the old HTML control events handler is always
    executed on the client site ?

    4.The new webb server control is these always executed on the server side ?

    5. My last question is it any point when creating new asp application to use
    the old HTML control ?

    //Tony
     
    Tony Johansson, Nov 30, 2010
    #1
    1. Advertising

  2. Tony Johansson

    Brian Cryer Guest

    "Tony Johansson" <> wrote in message
    news:id30ga$ftl$-september.org...
    > Hello!
    >
    > I'm trying to understand these two types of control which are the new web
    > control and the old style HTML control that
    > originated from the standard asp time.
    > I hope to get an answer to these questions.
    >
    > 1. This type
    > <input id="Submit1" runat="server" type="submit" value="submit"
    > onclick="return Submit1_onclick()" />
    > is the old HTML control. When I click this button event handler
    > Submit1_onclick() is executed. But where is it executed is it on the
    > server or on the Client ?


    onclick is specifying a JavaScript function to call. So "Submit1_onclick()"
    will be executed on the client.

    > The strange thing here is that when I click the submit button the
    > Page_Load on the server is called. whch means that this cause a postback.


    type="submit" means that the button will submit the form, which is why
    Page_Load is being called.

    > 2. Does it matter if I have runat="server" included or not when I use the
    > old HTML control.?


    No. By including runat="server" you provide the option of being able to make
    some changes to the button at the server end - but your options are very
    limited, if you want to be able to manipulate the button at all then it woul
    dbe better to use an asp:button.

    > 3. Is it possible to say that the old HTML control events handler is
    > always executed on the client site ?


    Its not the "old HTML" handler, its simply a JavaScript event handler.
    JavaScript is always executed on the client.

    > 4.The new webb server control is these always executed on the server side
    > ?


    Yes, but ... for most asp.net controls you can associate JavaScript if you
    want, but in general I wouldn't.

    > 5. My last question is it any point when creating new asp application to
    > use the old HTML control ?


    Probably in some scenarios. If you know what you are doing and know that
    what you want can be done just client side then it might make some sense. In
    general you can do so much more server side. I'm not sure I can think of any
    case since starting with asp.net when I've wanted to use a standard html
    control instead of its asp.net equivalent. So I'd advise always using the
    asp.net controls unless you know of a very good reason not to - in any event
    the asp.net controls get converted to standard html ones by the framework
    and you can always apply your own javascript if there is a need (but there
    rarely is).

    Hope this helps.
    --
    Brian Cryer
    http://www.cryer.co.uk/brian
     
    Brian Cryer, Dec 1, 2010
    #2
    1. Advertising

  3. Really good explained Brian Cryer

    Many thanks!!

    //Tony

    "Brian Cryer" <> skrev i meddelandet
    news:id550l$agr$-september.org...
    > "Tony Johansson" <> wrote in message
    > news:id30ga$ftl$-september.org...
    >> Hello!
    >>
    >> I'm trying to understand these two types of control which are the new web
    >> control and the old style HTML control that
    >> originated from the standard asp time.
    >> I hope to get an answer to these questions.
    >>
    >> 1. This type
    >> <input id="Submit1" runat="server" type="submit" value="submit"
    >> onclick="return Submit1_onclick()" />
    >> is the old HTML control. When I click this button event handler
    >> Submit1_onclick() is executed. But where is it executed is it on the
    >> server or on the Client ?

    >
    > onclick is specifying a JavaScript function to call. So
    > "Submit1_onclick()" will be executed on the client.
    >
    >> The strange thing here is that when I click the submit button the
    >> Page_Load on the server is called. whch means that this cause a postback.

    >
    > type="submit" means that the button will submit the form, which is why
    > Page_Load is being called.
    >
    >> 2. Does it matter if I have runat="server" included or not when I use
    >> the old HTML control.?

    >
    > No. By including runat="server" you provide the option of being able to
    > make some changes to the button at the server end - but your options are
    > very limited, if you want to be able to manipulate the button at all then
    > it woul dbe better to use an asp:button.
    >
    >> 3. Is it possible to say that the old HTML control events handler is
    >> always executed on the client site ?

    >
    > Its not the "old HTML" handler, its simply a JavaScript event handler.
    > JavaScript is always executed on the client.
    >
    >> 4.The new webb server control is these always executed on the server side
    >> ?

    >
    > Yes, but ... for most asp.net controls you can associate JavaScript if you
    > want, but in general I wouldn't.
    >
    >> 5. My last question is it any point when creating new asp application to
    >> use the old HTML control ?

    >
    > Probably in some scenarios. If you know what you are doing and know that
    > what you want can be done just client side then it might make some sense.
    > In general you can do so much more server side. I'm not sure I can think
    > of any case since starting with asp.net when I've wanted to use a standard
    > html control instead of its asp.net equivalent. So I'd advise always using
    > the asp.net controls unless you know of a very good reason not to - in any
    > event the asp.net controls get converted to standard html ones by the
    > framework and you can always apply your own javascript if there is a need
    > (but there rarely is).
    >
    > Hope this helps.
    > --
    > Brian Cryer
    > http://www.cryer.co.uk/brian
    >
     
    Tony Johansson, Dec 1, 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. Domino
    Replies:
    5
    Views:
    397
    dorayme
    Nov 5, 2006
  2. Jim Hill
    Replies:
    3
    Views:
    411
    Jim Hill
    Feb 12, 2007
  3. *Prot3anThr3ad*

    old repository for old C++ source code

    *Prot3anThr3ad*, Sep 29, 2006, in forum: C++
    Replies:
    6
    Views:
    390
    *Prot3anThr3ad*
    Oct 2, 2006
  4. DartGuru
    Replies:
    4
    Views:
    2,712
    Chaddy2222
    Oct 23, 2007
  5. John Henry
    Replies:
    24
    Views:
    1,027
    alex23
    May 30, 2008
Loading...

Share This Page