Control must be placed inside a form tag

J

John

Hi

I have dragged a few controls over to a web form. The html code generated is
as follows;

<asp:TextBox id="StaffCode" runat="server"></asp:TextBox>&nbsp;
<asp:Button id="Submit" runat="server"
Text="Submit"></asp:Button>&nbsp;&nbsp;
<asp:RequiredFieldValidator id="RequiredFieldValidator1" runat="server"
ErrorMessage="Code field can not be blank." Width="192px"
ControlToValidate="StaffCode"></asp:RequiredFieldValidator>

When I run the web form I get the following message;

Control 'StaffCode' of type 'TextBox' must be placed inside a form tag with
runat=server

What changes do I need to make to my web form? Obviously I am very new to
asp.net.

Thanks

Regards
 
G

Greg Burns

<HTML>
<body>
<form method="post" runat="server">

<asp:TextBox id="StaffCode" runat="server"></asp:TextBox>&nbsp;
<asp:Button id="Submit" runat="server"
Text="Submit"></asp:Button>&nbsp;&nbsp;
<asp:RequiredFieldValidator id="RequiredFieldValidator1" runat="server"
ErrorMessage="Code field can not be blank." Width="192px"
ControlToValidate="StaffCode"></asp:RequiredFieldValidator>

</form>
</body>
</HTML>

Greg
 
M

mapibaby

Hi Greg! I also encountered same problem. An error displays, "Control
'LAST_NAME' of type 'TextBox' must be placed inside a form tag with
runat=server." When I tried putting "runat=Server" inside the form
tag, the textbox wouldn't show up as well as the button.

Can you please help me?

Many thanks!

*-----------------------*
Posted at:
www.GroupSrv.com
*-----------------------*
 

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

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,818
Latest member
Brigette36

Latest Threads

Top