I have been attempting this all morning with no results. I can't seem to figure out what I'm doing wrong. I have checked out the two links (among many other unhelpful links) and have yet to solve my issue. This is a WebUserControl...
Receiving the following error: Control 'HeadContent_CareersViewPosting_txtFirstName' of type 'TextBox' must be placed inside a form tag with runat=server.
Already attempted the suggestions here, here and here and no results. Still received the exact same message. Some new suggestions would be greatly appreciated!
<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="Careers View Posting.ascx.cs" Inherits="ascxStagingApplication.Careers.Careers_View_Posting" %>
<asp:Panel ID="pnlResume" runat="server">
<table ID="tblMain" runat="server">
<tr>
<td>
<asp:Label ID="lblFirstName" runat="server" Text="* First Name"></asp:Label>
</td>
<td>
<asp:TextBox ID="txtFirstName" runat="server"></asp:TextBox>
</td>
</tr>
<tr>
<td>
<asp:Label ID="lblLastName" runat="server" Text="* Last Name"></asp:Label>
</td>
<td>
<asp:TextBox ID="txtLastName" runat="server"></asp:TextBox>
</td>
</tr>
<tr>
<td>
<asp:Label ID="lblEmail" runat="server" Text="* Email"></asp:Label>
</td>
<td>
<asp:TextBox ID="txtEmail" runat="server"></asp:TextBox>
</td>
</tr>
<tr>
<td>
<asp:Label ID="lblResume" runat="server" Text="* Resume"></asp:Label>
</td>
<td>
<asp:FileUpload ID="fupResume" runat="server" />
</td>
</tr>
<tr>
<td>
<asp:Button ID="btnSubmit" runat="server" Text="Submit"/>
</td>
</tr>
</table>
</asp:Panel>
The user control is currently being placed onto a dummy webpage for testing. Here is the 'dummy' page code.
<%@ Page Title="" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="Page Careers View Posting.aspx.cs" Inherits="ascxStagingApplication.Careers.Page_Careers_View_Posting" %>
<%@ Register Src="~/Careers/Careers View Posting.ascx" TagPrefix="uc1" TagName="CareersViewPosting" %>
<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="server">
<uc1:CareersViewPosting runat="server" id="CareersViewPosting" />
</asp:Content>
All server controls must appear within a
<form>
tag, and the<form>
tag must contain therunat="server"
attribute.All the Asp.net controls are server controls,so these should be placed within form tag with
runat="server"
attribute, like thisyou can add
In ASPNet webforms - everything needs to run within a form tag.
All server controls must appear within a
<form>
tag, and the<form>
tag must contain therunat="server"
attribute. Therunat="server"
attribute indicates that the form should be processed on the server. It also indicates that the enclosed controls can be accessed by server scripts:In your dummy page try the following to allow the server controls to run.
Also - check that your ~/Site.Master file contains the
<form runat="server">
if not -a s it would be fairly typical for that to be the place to have your all enclosing form tag.You could read more here: http://www.w3schools.com/aspnet/aspnet_forms.asp
If you put right of runat="server" but still error, please try this code.
cr. from Rohit Rao
sorry for my bad skill English.