views:

30

answers:

2

All,

I've noticed that asp.net includes a closing slash on the viewstate form field:

<input type="hidden" name="__VIEWSTATE" id="__VIEWSTATE" value="blah blah blah" />

How can I prevent this from happening? We're rendering html 4.01 strict and this seems to be noncompliant.

+1  A: 

Try configuring it to use HTML 4.01 as described here ("Legacy" setting).

Pavel Minaev
No joy, unfortunately.
David Lively
+1  A: 

The final answer I've arrived at is "this doesn't matter." For better or worse, these tags are generated how the framework wants to generate them, and there's not a lot you can do about it other than create an HttpModule that would reformat the tags before the markup is sent to the browser.

However, it doesn't matter. Validation on these tags is irrelevant. Another developer complained that the underscores in the tag names ("__VIEWSTATE" for example) are noncompliant, as well, but it turns out that is is a CSS rule, not an HTML rule. Since no style is applied to these tags (and it wouldn't make sense to apply CSS to a hidden element) the lack of CSS compliance is irrelevant.

Happy coding.

David Lively