Click here to Skip to main content
15,886,258 members
Please Sign up or sign in to vote.
2.00/5 (1 vote)
So I am trying to get a file upload working in Visual Studio 2010 using ASP.Net 3.5 and C#, I grabbed the code from http://asp.net-tutorials.com/controls/file-upload-control/[^] and looked at some information on here for "The name 'Path' does not exist in the current context". I had solved the Issue with the second issue by adding "using System.IO" in the codebehind code. Now when i launch the page in debug mode i am getting this error:

Server Error in '/' Application.

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

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Web.HttpException: A page can have only one server-side Form tag.

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace:


[HttpException (0x80004005): A page can have only one server-side Form tag.]
System.Web.UI.Page.OnFormRender() +8785224
System.Web.UI.HtmlControls.HtmlForm.RenderChildren(HtmlTextWriter writer) +33
System.Web.UI.HtmlControls.HtmlContainerControl.Render(HtmlTextWriter writer) +32
System.Web.UI.HtmlControls.HtmlForm.Render(HtmlTextWriter output) +51
System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +27
System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter) +99
System.Web.UI.HtmlControls.HtmlForm.RenderControl(HtmlTextWriter writer) +40
System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) +134
System.Web.UI.Control.RenderChildren(HtmlTextWriter writer) +19
System.Web.UI.Control.Render(HtmlTextWriter writer) +10
System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +27
System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter) +99
System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +25
System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) +134
System.Web.UI.Control.RenderChildren(HtmlTextWriter writer) +19
System.Web.UI.HtmlControls.HtmlForm.RenderChildren(HtmlTextWriter writer) +163
System.Web.UI.HtmlControls.HtmlContainerControl.Render(HtmlTextWriter writer) +32
System.Web.UI.HtmlControls.HtmlForm.Render(HtmlTextWriter output) +51
System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +27
System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter) +99
System.Web.UI.HtmlControls.HtmlForm.RenderControl(HtmlTextWriter writer) +40
System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) +134
System.Web.UI.Control.RenderChildren(HtmlTextWriter writer) +19
System.Web.UI.Control.Render(HtmlTextWriter writer) +10
System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +27
System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter) +99
System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +25
System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) +134
System.Web.UI.Control.RenderChildren(HtmlTextWriter writer) +19
System.Web.UI.Page.Render(HtmlTextWriter writer) +29
System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +27
System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter) +99
System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +25
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1266

Version Information: Microsoft .NET Framework Version:2.0.50727.5472; ASP.NET Version:2.0.50727.5471


also if someone can direct to a site where i can post code so i can link to it so you all can see what i have written. Just incase its code some where else.
Posted
Comments
idenizeni 31-Aug-13 15:42pm    
Are you using a master page with a form control in it? If so remove the form control from the page you setup the file upload in. Edit: And you can post your code here. Update your post and add the code, use the pre tags so the code is styled for easier reading.
Steven Tidwell 31-Aug-13 15:54pm    
Oh my god...that was so simple....and yet I over looked that thank you for your help.
idenizeni 31-Aug-13 15:58pm    
You're welcome. I went ahead and posted my comment as a solution in case you wanted to mark it.
Steven Tidwell 31-Aug-13 15:59pm    
Totally new to codeproject so okay and i accepted it i believe
idenizeni 31-Aug-13 16:01pm    
Yep you did, it's marked as the solution. Thanks, and welcome to CodeProject :)

Are you using a master page with a form control in it? If so remove the form control from the page you setup the file upload in.
 
Share this answer
 
The error is very clear. You have used more than one Form tags in your page. May be you have a form control in your master page as well as the page in which you are placing the file upload control. Or may be by mistake you have added two form controls in the same page. Just remove one and things will start working fine.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900