runat=server

  • Thread starter Thread starter Tony Johansson
  • Start date Start date
T

Tony Johansson

Hello!

Almost all runat="server" is located to web server control but there are
some exceptions.
In all books I have read we have runat="server" on the head element and on
the form element we also have the runat="server"

If I remove this runat="server" on the form element I get an exception
saying
"The control nameBox of the type TextBox must be placed within the formtag
with the attribute runat="server"
I can understand that.

But I can remove the runat="server" on the head element without any problem
and the application work just the same.
So my first question is what is the point to have runat="server" on the head
element when it work just the same without it ?
All books that I have read have this so it can't be a typo

My second question is
Which more htlm element used to have the runat="server" attribute.


//Tony
 
Almost all runat="server" is located to web server control but there are
some exceptions.
In all books I have read we have runat="server" on the head element and on
the form element we also have the runat="server"

If I remove this runat="server" on the form element I get an exception
saying
"The control nameBox of the type TextBox must be placed within the formtag
with the attribute runat="server"
I can understand that.

But I can remove the runat="server" on the head element without any problem
and the application work just the same.
So my first question is what is the point to have runat="server" on the head
element when it work just the same without it ?
All books that I have read have this so it can't be a typo

My second question is
Which more htlm element used to have the runat="server" attribute.

<head>
....
</head>

is literal HTML.

<head id="myhead" runat="server">
....
</head>

is a HTML control more specifically:

http://msdn.microsoft.com/en-us/library/system.web.ui.htmlcontrols.htmlhead.aspx

The difference is that:
- literal HTML is (almost) out of programmatic control
- HTML controls can be manipulated by code

You should only use HTML controls if you actually want to
manipulate them.

Arne
 
Good answer Arne.

You are one of the best to know how to answer my questions.

//Tony
 
Back
Top