Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why .NET strips off one <form> tag from the page if there is already a form with runat server attribute?

It doesn't remove everything inside the 2nd form tag but just hides the and tags from the page

Any ideas and workaround?

like image 439
Zubair Ahmed Avatar asked Dec 21 '08 11:12

Zubair Ahmed


People also ask

Can we have two form tag in ASPX page?

Yes, it can be done - by creating a custom HtmlForm object and toggling the forms as needed. I've just answered a similar question here (with code):

How many form tags are allowed in a asp net web page?

ASP.NET Web Forms technology doesn't allow more than one <form> tags with runat=“server” on a single Web Form page.

Can form tags be nested?

Every form must be enclosed within a FORM element. There can be several forms in a single document, but the FORM element can't be nested.

Is form tag necessary in asp net?

All server controls must appear within a <form> tag, and the <form> tag must contain the runat="server" attribute.


2 Answers

Nesting of forms is not allowed in html. So you cant add another form inside the server-form.

But it is perfectly legal in ASP.NET to add get-forms outside of the server form.

like image 122
user48112 Avatar answered Oct 18 '22 23:10

user48112


I moved the nested form outside to solve this issue.

like image 41
Zubair Ahmed Avatar answered Oct 18 '22 22:10

Zubair Ahmed