A page can have only one server-side Form tag in ASP.net
I'm new to ASP.net and I'm trying to run the following ASP.net code, but it's giving me an error : A page can have only one server-side Form tag .
<%@ Page Title="Home Page" Language="C#" MasterPageFile="~/Site.master" AutoEventWireup="true"
CodeBehind="Default.aspx.cs" Inherits="FirstWebsite._Default" %>
<asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="MainContent">
<form id="form1" runat="server">
<div>
<asp:Label runat="server" id="HelloWorldLabel"></asp:Label>
<br /><br />
<开发者_运维百科;asp:TextBox runat="server" id="TextInput" />
<asp:Button runat="server" id="GreetButton" text="Say Hello!" />
</div>
</form>
</asp:Content>
Could anyone please tell me what's wrong I'm doing?
Your Masterpage probably has a Form tag as well.
If you want to do multiple Form tags, remove the runat="server"
attribute and use plain HTML input tags instead.
You are using the master page and the master page would have the form tag. So remove it from this page.
<%@ Page Title="Home Page" Language="C#" MasterPageFile="~/Site.master" AutoEventWireup="true"
CodeBehind="Default.aspx.cs" Inherits="FirstWebsite._Default" %>
<asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="MainContent">
<div>
<asp:Label runat="server" id="HelloWorldLabel"></asp:Label>
<br /><br />
<asp:TextBox runat="server" id="TextInput" />
<asp:Button runat="server" id="GreetButton" text="Say Hello!" />
</div>
</asp:Content>
精彩评论