runat=server

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
 
A

Arne Vajhøj

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
 
T

Tony Johansson

Good answer Arne.

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

//Tony
 

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

Top