Control must be placed inside a form tag

  • Thread starter Thread starter John
  • Start date Start date
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
 
<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
 
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
*-----------------------*
 
Back
Top