Why does .NET remove one <form> tag from the page if there already exists a form with the runat server attribute?

It doesn't remove everything inside the 2nd form tag, it just hides the tags from the page too

Any ideas and workarounds?

+5


source to share


4 answers


I moved the nested form to the outside to solve this problem.



+2


source


Httml attachments are not allowed. This way you cannot add another form inside the server form.



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

+5


source


You don't have nested form tags. Go to asp.net mvc if you want more control over the markup or not use ASP.NET controls, that way you can include multiple form tags without requiring the controls to be in a form tag with a runat server attribute, but then you don't get granular access in the code behind and should start using the request.form method to get the postback values.

+1


source


The reason ASP.NET covers everything in one form is that when a postback occurs, the entire form is submitted back to the server and you will have access to every element on the page.

That is, you can change the properties of the elements ( myTextbox.Text = 'Hello';

) from the code-behind.

0


source







All Articles