943,892 Members | Top Members by Rank

Ad:
  • ASP.NET Discussion Thread
  • Unsolved
  • Views: 509
  • ASP.NET RSS
Jul 2nd, 2009
0

Error in asp net

Expand Post »
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
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
gobi_roy is offline Offline
3 posts
since Jan 2009
Jul 2nd, 2009
0

Re: Error in asp net

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:
asp.net Syntax (Toggle Plain Text)
  1. <%@ Master Language="C#" AutoEventWireup="true" CodeBehind="Site1.master.cs" Inherits="daniweb.web.Site1" %>
  2. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  3. <html xmlns="http://www.w3.org/1999/xhtml" >
  4. <head runat="server">
  5. <link rel="stylesheet" href="Stylesheet1.css" type="text/css" />
  6. <title>Master Page</title>
  7. <asp:ContentPlaceHolder ID="head" runat="server">
  8. </asp:ContentPlaceHolder>
  9. </head>
  10. <body>
  11. <form id="form1" runat="server">
  12. <center>
  13. <asp:ContentPlaceHolder id="ContentPlaceHolder1" runat="server">
  14. </asp:ContentPlaceHolder>

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

asp.net Syntax (Toggle Plain Text)
  1. <%@ Page Title="" Language="C#" MasterPageFile="~/Site1.Master" AutoEventWireup="true" CodeBehind="Page1.aspx.cs" Inherits="daniweb.web.Page1" %>
  2. <asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
  3. </asp:Content>
  4. <asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
  5. <form id="hello" runat="server">
  6. <asp:Button ID="Button1" runat="server" onclick="Button1_Click" Text="Button" OnClientClick="javascript:self.close(); " />
  7. </form>
  8. </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:
asp.net Syntax (Toggle Plain Text)
  1. <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="daniweb.web.Default" %>
  2.  
  3. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  4.  
  5. <html xmlns="http://www.w3.org/1999/xhtml" >
  6. <head runat="server">
  7. <title></title>
  8. </head>
  9. <body>
  10. <form id="form1" runat="server">
  11. <div>
  12. <form id="form2" runat="server">
  13. <p>hello</p>
  14. </form>
  15. </div>
  16. </form>
  17. </body>
  18. </html>
Last edited by sknake; Jul 2nd, 2009 at 3:20 pm.
Featured Poster
Reputation Points: 1749
Solved Threads: 735
Senior Poster
sknake is offline Offline
3,948 posts
since Feb 2009
Jul 2nd, 2009
-1

Re: Error in asp net

Quote ...
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.
Reputation Points: 3
Solved Threads: 14
Junior Poster
thewebhostingdi is offline Offline
168 posts
since Jun 2009
Jul 2nd, 2009
0

Re: Error in asp net

please mark this thread as solved.
Featured Poster
Reputation Points: 854
Solved Threads: 127
Banned
serkan sendur is offline Offline
2,057 posts
since Jan 2008

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in ASP.NET Forum Timeline: selected detail info
Next Thread in ASP.NET Forum Timeline: asp.net stylesheet





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC