Some question about web control and the old HTML control

T

Tony Johansson

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
 
B

Brian Cryer

Tony Johansson said:
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.
 

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

No members online now.

Forum statistics

Threads
473,743
Messages
2,569,478
Members
44,898
Latest member
BlairH7607

Latest Threads

Top