Must be Placed Inside a Form Tag With runat=server

假装没事ソ 提交于 2019-12-05 00:03:05
Martin Brown

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 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.

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.

 public override void VerifyRenderingInServerForm(Control control)
    {
         /* Confirms that an HtmlForm control is rendered for the specified ASP.NET
       server control at run time. */
    }

cr. from Rohit Rao

sorry for my bad skill English.

Rae Lee

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

<form runat="server">

place server controls here...

</form>

you can add

<form runnat="server">
 // add content placeholder
</form>
Adnan
>Button bt = new Button();
>bt.ID = "dd";
>bt.Text = "Click Me";
>this.Form.Controls.Add(bt);
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!