Problem:
I use a masterfile. The page account.aspx loads in contentplaceholder3. I have created a form in my account.aspx, but when I try to add a 'ASP:textbox' field to my contact.aspx , I get a: "'TEXTBOX' must be placed inside a form tag with runat=server" error.
When I do this, I get a: "A page can have only one server-side Form tag" error. So I don't know what to do now!
thx
please mark answers as 'Answered' and post back solutions when you figure stuff out that isnt in the post already.
The error, in this case, describes the problem pretty well. Your page, at run-time, can only have a single form with the runat="server" attribute. I do believe that you can have other forms though, you would just have to use the older Request.Form method to
get any field values from them.
Do you get this error from the designer? And are you setting the masterPageFile via web.config? If so, then this is a designer issue, not an ASP.NET issue. Your page should run just fine. This complaint from VS.NET occurs since VS.NET is not reading web.config
for the masterPageFile and then assumes you're not using a master page and then thinks you're missing the <html> tags. If this is actually your problem, then like I said, your page should actually execute alright and you can ignore the incorrect errors VS.NET
is reporting.
Ok, problem solved. The problem was that I have a masterpage file and a content file with a form. Even though I had commented the form tag in the masterpage file, this still got parsed in the code for some reason. Completely removing the tags from the masterpage
did the trick and now my form in the content page works fine!
please mark answers as 'Answered' and post back solutions when you figure stuff out that isnt in the post already.
Marked as answer by Mikesdotnetting on Sep 07, 2010 09:42 PM
This raises a good question about location. When building Master Pages is it best to leave the form tag on the Master Page on in the appropriate content section?
In the MasterPage. Because you can't have more than one server side form tag. If you have the form tag in the MasterPage, you don't need to add it to each content page.
The problem is when the content page needs to perform a form based action and then the master page form tag conflicts with this. I noticed this currently in my site. I have a content page that is doing an action in its form tag. Because there is a form tag
in the master page, it clobbers the content page's form tag from doing what it needs to do, move that page out of a master page scenario and it works. I tried removing the master page's form tag but that only caused menu controls to complain. Anyone figure
out a reasonable solution to this??
Peter Smith
Contributor
4605 Points
2109 Posts
A page can have only one server-side Form tag
Mar 28, 2005 12:35 PM|LINK
Problem:
I use a masterfile. The page account.aspx loads in contentplaceholder3. I have created a form in my account.aspx, but when I try to add a 'ASP:textbox' field to my contact.aspx , I get a: "'TEXTBOX' must be placed inside a form tag with runat=server" error. When I do this, I get a: "A page can have only one server-side Form tag" error. So I don't know what to do now!
thx
NetProfit
Contributor
6278 Points
1252 Posts
Re: A page can have only one server-side Form tag
Mar 28, 2005 01:04 PM|LINK
Hi Peter,
What version of ASP.Net are you using?
Peter Smith
Contributor
4605 Points
2109 Posts
Re: A page can have only one server-side Form tag
Mar 28, 2005 01:19 PM|LINK
ChrisWallace
Member
55 Points
11 Posts
Re: A page can have only one server-side Form tag
Mar 28, 2005 06:44 PM|LINK
Luis Abreu
All-Star
25674 Points
5369 Posts
MVP
Re: A page can have only one server-side Form tag
Mar 28, 2005 07:17 PM|LINK
Hello.
Could you show us the code you're using?
Regards,
Luis Abreu
email: labreu_at_gmail.com
EN blog:http://msmvps.com/blogs/luisabreu
BrockAllen
All-Star
27574 Points
4912 Posts
MVP
Re: A page can have only one server-side Form tag
Mar 28, 2005 10:41 PM|LINK
Do you get this error from the designer? And are you setting the masterPageFile via web.config? If so, then this is a designer issue, not an ASP.NET issue. Your page should run just fine. This complaint from VS.NET occurs since VS.NET is not reading web.config for the masterPageFile and then assumes you're not using a master page and then thinks you're missing the <html> tags. If this is actually your problem, then like I said, your page should actually execute alright and you can ignore the incorrect errors VS.NET is reporting.
-Brock
DevelopMentor | http://www.develop.com
thinktecture | http://www.thinktecture.com/
Peter Smith
Contributor
4605 Points
2109 Posts
Re: A page can have only one server-side Form tag
Mar 29, 2005 05:41 AM|LINK
rcurtis
Member
321 Points
78 Posts
Re: A page can have only one server-side Form tag
Apr 04, 2005 04:03 AM|LINK
This raises a good question about location. When building Master Pages is it best to leave the form tag on the Master Page on in the appropriate content section?
Rick
Fredrik N
All-Star
29674 Points
5334 Posts
MVP
Re: A page can have only one server-side Form tag
Apr 04, 2005 07:06 AM|LINK
In the MasterPage. Because you can't have more than one server side form tag. If you have the form tag in the MasterPage, you don't need to add it to each content page.
MVP, ASPInsider, WCF RIA Services Insider
My Blog
Armysniper
Participant
999 Points
292 Posts
Re: A page can have only one server-side Form tag
Aug 01, 2005 08:56 PM|LINK