0

hi,
there, i need to know why is it i get this error when i run the web site.A page can have only one server-side Form tag

4
Contributors
3
Replies
4
Views
7 Years
Discussion Span
Last Post by serkan sendur
0

This can happen if you are using master pages and you have a <form runat="server"> element in your master page and in your web content page you have another <form runat="server"> . Here is an example.

Master Page:

<%@ Master Language="C#" AutoEventWireup="true" CodeBehind="Site1.master.cs" Inherits="daniweb.web.Site1" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <link rel="stylesheet" href="Stylesheet1.css" type="text/css" />
    <title>Master Page</title>
    <asp:ContentPlaceHolder ID="head" runat="server">
    </asp:ContentPlaceHolder>
</head>
<body>
    <form id="form1" runat="server">
    <center> 
            <asp:ContentPlaceHolder id="ContentPlaceHolder1" runat="server">
            </asp:ContentPlaceHolder>

Note in the above example the content place holder is inside the <form> element. Now on your child page:

<%@ Page Title="" Language="C#" MasterPageFile="~/Site1.Master" AutoEventWireup="true" CodeBehind="Page1.aspx.cs" Inherits="daniweb.web.Page1" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
	<form id="hello" runat="server">
		<asp:Button ID="Button1" runat="server" onclick="Button1_Click" Text="Button" OnClientClick="javascript:self.close(); " />
	</form>
</asp:Content>

Resulting in: [HttpException (0x80004005): A page can have only one server-side Form tag.] Here is an example of two embedded forms causing that error without using master pages:

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="daniweb.web.Default" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
			<form id="form2" runat="server">
				<p>hello</p>
			</form>
    </div>
    </form>
</body>
</html>
-1

A page can have only one server-side Form tag

As the error message itself suggests, a web page can have only one run at server form tag.

Please check your markup, you must have more than one form tags written there.

Votes + Comments
worthless post
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.