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...
我整个上午一直在尝试这个,没有结果。我似乎无法弄清楚我做错了什么。我已经检查了两个链接(在许多其他无用的链接中)并且尚未解决我的问题。这是一个WebUserControl ......
Receiving the following error: Control 'HeadContent_CareersViewPosting_txtFirstName' of type 'TextBox' must be placed inside a form tag with runat=server.
收到以下错误:控件'TextBox'类型的'HeadContent_CareersViewPosting_txtFirstName'必须放在带有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>
5 个解决方案
#1
13
In ASPNet webforms - everything needs to run within a form tag.
在ASPNet webforms中 - 一切都需要在表单标记中运行。
All server controls must appear within a <form>
tag, and the <form>
tag must contain the runat="server"
attribute. The runat="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:
所有服务器控件必须出现在
<form runat="server">
...HTML + server controls
</form>
In your dummy page try the following to allow the server controls to run.
在您的虚拟页面中,尝试以下操作以允许服务器控件运行。
<%@ 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" %>
<form runat="server">
<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="server">
<uc1:CareersViewPosting runat="server" id="CareersViewPosting" />
</asp:Content>
</form>
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.
另外 - 检查你的〜/ Site.Master文件是否包含
You could read more here: http://www.w3schools.com/aspnet/aspnet_forms.asp
你可以在这里阅读更多内容:http://www.w3schools.com/aspnet/aspnet_forms.asp
#2
0
All server controls must appear within a <form>
tag, and the <form>
tag must contain the runat="server"
attribute.
所有服务器控件必须出现在
All the Asp.net controls are server controls,so these should be placed within form tag with runat="server"
attribute, like this
所有Asp.net控件都是服务器控件,因此这些控件应放在带有runat =“server”属性的form标签中,如下所示
<form runat="server">
place server controls here...
</form>
#3
0
enter code here
在此处输入代码
<asp:ContentPlaceHolder ID="ContentPlaceHolder1" runat="server">
</asp:ContentPlaceHolder>
</form>
#4
-2
>Button bt = new Button();
>bt.ID = "dd";
>bt.Text = "Click Me";
>this.Form.Controls.Add(bt);
#5
-3
you can add
你可以加
<form runnat="server">
// add content placeholder
</form>
#1
13
In ASPNet webforms - everything needs to run within a form tag.
在ASPNet webforms中 - 一切都需要在表单标记中运行。
All server controls must appear within a <form>
tag, and the <form>
tag must contain the runat="server"
attribute. The runat="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:
所有服务器控件必须出现在
<form runat="server">
...HTML + server controls
</form>
In your dummy page try the following to allow the server controls to run.
在您的虚拟页面中,尝试以下操作以允许服务器控件运行。
<%@ 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" %>
<form runat="server">
<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="server">
<uc1:CareersViewPosting runat="server" id="CareersViewPosting" />
</asp:Content>
</form>
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.
另外 - 检查你的〜/ Site.Master文件是否包含
You could read more here: http://www.w3schools.com/aspnet/aspnet_forms.asp
你可以在这里阅读更多内容:http://www.w3schools.com/aspnet/aspnet_forms.asp
#2
0
All server controls must appear within a <form>
tag, and the <form>
tag must contain the runat="server"
attribute.
所有服务器控件必须出现在
All the Asp.net controls are server controls,so these should be placed within form tag with runat="server"
attribute, like this
所有Asp.net控件都是服务器控件,因此这些控件应放在带有runat =“server”属性的form标签中,如下所示
<form runat="server">
place server controls here...
</form>
#3
0
enter code here
在此处输入代码
<asp:ContentPlaceHolder ID="ContentPlaceHolder1" runat="server">
</asp:ContentPlaceHolder>
</form>
#4
-2
>Button bt = new Button();
>bt.ID = "dd";
>bt.Text = "Click Me";
>this.Form.Controls.Add(bt);
#5
-3
you can add
你可以加
<form runnat="server">
// add content placeholder
</form>