开发者

w3c validation issues

im confused, the w3c validation service seems to be saying that asp.net cannot legally render a hidden field inside a form tag on the page, have a look at this ...

http://validator.w3.org/check?uri=http%3a%2f%2fmotcombegarage%2eco%2euk开发者_开发技巧%2f

from what i can tell it seems to be saying that the following code sample is invalid markup WTF !!!

<html>
<head> ... header stuff ... </head>
<body>
  <form method="post" action="" id="ctl01">
    <div class="aspNetHidden">
      <input type="hidden" name="ctl09_HiddenField" id="ctl09_HiddenField" value="" />
      <input type="hidden" name="__VIEWSTATE" id="__VIEWSTATE" value="/wEPDwUKMTY1NzEyODQ1M2RkJPtW5VtaL7LPuSxnn1JM1yVnOeGAovb8b4b3KShHy4M=" />
      <input type="hidden" name="__EVENTVALIDATION" id="__EVENTVALIDATION" value="/wEWAwKt17cxAr+s9MgFAqjXzJsHz7KyzLpZjYtTK89blY7GgKAElK/5syvVNn4h7rVehcQ=" />
    </div>
     ... other code ...
  </form>
</body>
</html>

This presents 2 problems for me if the code is in fact invalid:

  1. This code is generated by the .net framework for handling postbacks so editing it could be a problem
  2. i have no idea what the valid context for a form field should be (lolz)

Is this a bug or have i done something wrong ???

EDIT: As pointed out by Peter O below I added the missing div tag in my markup ... comparing this to the markup that the validator uses shows that this div whilst present in the markup is apparently not worth validating ... so that kinda changes the question to ... why is it ignoring that div ? ...

Seems a bit odd that you can't put an input tag inside a form tag directly though ... surely thats the point of a form tag, to contain input tags ??


The only way I've seemed to get rid of the message, following the code on your homepage, is to assign a value to the first hidden input

<div class="aspNetHidden">
<input type="hidden" name="ctl09_HiddenField" id="ctl09_HiddenField" value="toverton" />
<input type="hidden" name="__EVENTTARGET" id="__EVENTTARGET" value="" />
<input type="hidden" name="__EVENTARGUMENT" id="__EVENTARGUMENT" value="" />
<input type="hidden" name="__VIEWSTATE" id="__VIEWSTATE" value="/wEPDwUKMTY1NzEyODQ1M2RkJPtW5VtaL7LPuSxnn1JM1yVnOeGAovb8b4b3KShHy4M=" />
</div>

In all liklihood, this is most likely a bug.


The INPUT elements should be placed within a DIV element, like this:

<form ... >
  <div>
    <input type="hidden" ... />
    <input type="hidden" ... />
    <input type="hidden" ... />
  </div>
</form>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜