Error in asp net

Please support our ASP.NET advertiser: Intel Parallel Studio Home
Reply

Join Date: Jan 2009
Posts: 3
Reputation: gobi_roy is an unknown quantity at this point 
Solved Threads: 0
gobi_roy gobi_roy is offline Offline
Newbie Poster

Error in asp net

 
0
  #1
Jul 2nd, 2009
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
Reply With Quote Quick reply to this message  
Join Date: Feb 2009
Posts: 3,406
Reputation: sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of 
Solved Threads: 613
Sponsor
sknake's Avatar
sknake sknake is offline Offline
.NET Enthusiast

Re: Error in asp net

 
0
  #2
Jul 2nd, 2009
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:
  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:

  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:
  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.
Scott Knake
Custom Software Development
Apex Software, Inc.
Reply With Quote Quick reply to this message  
Join Date: Jun 2009
Posts: 124
Reputation: thewebhostingdi has a little shameless behaviour in the past 
Solved Threads: 11
thewebhostingdi thewebhostingdi is offline Offline
Junior Poster

Re: Error in asp net

 
-1
  #3
Jul 2nd, 2009
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.
Reply With Quote Quick reply to this message  
Join Date: Jan 2008
Posts: 2,052
Reputation: serkan sendur is a glorious beacon of light serkan sendur is a glorious beacon of light serkan sendur is a glorious beacon of light serkan sendur is a glorious beacon of light serkan sendur is a glorious beacon of light serkan sendur is a glorious beacon of light 
Solved Threads: 122
Featured Poster
serkan sendur serkan sendur is offline Offline
Postaholic

Re: Error in asp net

 
0
  #4
Jul 2nd, 2009
please mark this thread as solved.
Due to lack of freedom of speech, i no longer post on this website.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the ASP.NET Forum
Thread Tools Search this Thread



Tag cloud for ASP.NET
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC