Question

i am trying to put a textbox inside content page :

<%@ Page Title="" Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
<br /><br />

<br />
<form>
<asp:TextBox runat="server"></asp:TextBox>
</form>

</asp:Content>

and i am getting an error: "Control 'ContentPlaceHolder1_ctl00' of type 'TextBox' must be placed inside a form tag with runat=server."

when i'm trying to put runat="server" like this:

<%@ Page Title="" Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
<br /><br />

<br />
<form runat="server">
<asp:TextBox runat="server"></asp:TextBox>
</form>

</asp:Content>

i'm getting that error:

"A page can have only one server-side Form tag."

sombody can help please?

No correct solution

OTHER TIPS

You are using a Runat="Server" tag in your asp:Content tag. There is no need to have the tag in your Form and TextBox since they are within the same Master Page. In a Master Page you can only have one reference to the Runat="Server" tag.

I think you can should the form tag and place your textbox inside the asp:Content directly

Your master page also has a <form runat=server> tag. Either remove it from the master page or from your content page. You can only have one. I recomend you open up MasterPage.master and remove the form tag.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top