user5067119 user5067119 - 1 month ago 10
ASP.NET (C#) Question

Getting A page can have only one server-side Form tag Error

I have done my

MasterPage
and create a new
.aspx
page with this
MasterPage
. but whenever I try to add a
RadioButton
to the
.aspx
page it's generate to me this error:


Control 'head_ctl00' of type 'RadioButton' must be placed inside a
form tag with runat=server.


and I have tried to add a form tag and this error came out !


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


I'm confused how I can solve this problem ! any idea ?

in case you need my
.aspx
page :

<%@ Page Title="" Language="C#" MasterPageFile="~/MySite.Master" AutoEventWireup="true" CodeBehind="Registration.aspx.cs" Inherits="MyWebsite.Registration" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
<form id="frm" runat="server">
<asp:RadioButton runat="server"></asp:RadioButton>
</form>
</asp:Content>

Answer

You have inserted your RadioButton inside the head placeholder that has not the form tag in your MasterPage file. You should place RadioButton in another PlaceHolder like MainContent or FeaturedContent. Also you don't need the form tag in your ContentPages, The form tag on the master page will be sufficient.

Comments