By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
429,078 Members | 2,164 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 429,078 IT Pros & Developers. It's quick & easy.

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

P: n/a
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!


Nov 18 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
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.
-----Original Message-----
It happend to me more than once. When I create web controls or move thepositions in VS.NET, I encountered the following run- time errors: It doesn'tmatter what controls I create, the following 'checkbox' control is just anexample.
Control 'CheckBox1' of type 'CheckBox' must be placed inside a form tag withrunat=server.
Description: An unhandled exception occurred during the execution of thecurrent web request. Please review the stack trace for more informationabout 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 webrequest. Information regarding the origin and location of the exception canbe identified using the exception stack trace below.
I know it's very easy to solve the problem, we simply move the code insidethe 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 similarproblem before.

Please advise. Thanks!


.

Nov 18 '05 #2

P: n/a
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.

--
Teemu Keiski
MCP, Microsoft MVP (ASP.NET), AspInsiders member
ASP.NET Forum Moderator, AspAlliance Columnist

"Matthew Louden" <ma*******@hotmail.com> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
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!

Nov 18 '05 #3

P: n/a
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.
"Matthew Louden" <ma*******@hotmail.com> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
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!

Nov 18 '05 #4

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

--
Teemu Keiski
MCP, Microsoft MVP (ASP.NET), AspInsiders member
ASP.NET Forum Moderator, AspAlliance Columnist
"Teemu Keiski" <jo****@aspalliance.com> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
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.

--
Teemu Keiski
MCP, Microsoft MVP (ASP.NET), AspInsiders member
ASP.NET Forum Moderator, AspAlliance Columnist

"Matthew Louden" <ma*******@hotmail.com> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
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!


Nov 18 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.