views:

81

answers:

3

Whole code of Asp.net page renders in a form tag is it W3C valid to render everything in form tag?

<body>

  <form runat="server">

    remaining code.....

 </form>
</body>
+2  A: 

Considering this is how ASP.NET must operate, there's not much sense worrying about it.

All browsers support it and in all my complaint code that isn't ASP.NET I have to put all sorts of standard html tags between the <form></form> tag.

So yes, its valid.

Soviut
+1  A: 

Assuming you don't put another (non-runat="Server") form tag on this page, sure.

(because nested forms are invalid)

marcc
+1  A: 

Technically Yes. However this is bad practice.

However Soviut is correct in stating that ASP.Net requires this to operate, and generally disregards web standards wholesale. So short of dumping ASP.Net you may need to focus on mitigating the number of web standards you break rather than sticking to web standards.

The issue with having a tag surrounding the whole page is that you post everything on the page at once. This means that if you have a simple search form at the top of the page, and another form that users enter data with you cannot separate these form requests. This unneccisasarily increases the quantity of data that the user needs to send, as well as introducing other potentital issues.

If you have the choice, use MVC or some other technology instead.

Josiah
I don't really see it as bad practice since you often need to include tables, labels, descriptions, and other layout tags within your form. There's no real "illegal" tags you can't stick inside a form.
Soviut
It is true that you sometimes need to include these elements within a form, and doing so is not bad practice. However the way that forms are implemented in ASP.Net _is_ bad practice, because they encompass the whole page. This means that you are forced to use work-around's when you have two separate forms on one page.
Josiah