Run-time error: <Control Name> must be placed inside a form tag with runat=server

M

Matthew Louden

It happend to me more than once. When I create web controls or move the
positions in VS.NET, I encountered the following run-time errors: It doesn't
matter what controls I create, the following 'checkbox' control is just an
example.


Control 'CheckBox1' of type 'CheckBox' must be placed inside a form tag with
runat=server.
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information
about the error and where it originated in the code.

Exception Details: System.Web.HttpException: Control 'CheckBox1' of type
'CheckBox' must be placed inside a form tag with runat=server.

Source Error:

An unhandled exception was generated during the execution of the current web
request. Information regarding the origin and location of the exception can
be identified using the exception stack trace below.


I know it's very easy to solve the problem, we simply move the code inside
the form block as follows:

<form id="Form1" method="post" runat="server">
'UI code
</form>

Maybe it's bug in VS.NET. I just want to see if anyone encountered similar
problem before.

Please advise. Thanks!
 
J

Jim Heavey

All asp.net controls (i.e "<asp:') where the Runat=Server
must be within the form tag ( and I would guess even
those ASP controls which are not runat server, but not
absolutely sure about that) those asp.n and the form tag
must be runat=server as well.
 
T

Teemu Keiski

It's not a bug, it's a very much designed feature. Certain controls need to
exist inside a server form for them to work properly.
 
L

Lloyd Sheen

I know what you mean. I have had more IDE related problems with things like
this. Everything is ok , move a control and then things are wrong. I think
the IDE is about where VB2 was. Still not totally ready for prime time.

I keep losing toolbar buttons etc. and it is very frustrating.
 
T

Teemu Keiski

Or with second reading, if the problem is that IDE moves them out of the
form, then it could be a bug. :)
 

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,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top