简体   繁体   English

w3c验证问题

[英]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 ... 我很困惑,w3c验证服务似乎是说asp.net不能合法地在页面上的表单标签内呈现隐藏字段,看看这个......

http://validator.w3.org/check?uri=http%3a%2f%2fmotcombegarage%2eco%2euk%2f 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 !!! 从我可以告诉它似乎是说以下代码示例是无效标记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 此代码由.net框架生成,用于处理回发,因此编辑它可能是一个问题
  2. i have no idea what the valid context for a form field should be (lolz) 我不知道表单字段的有效上下文应该是什么(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 ? 编辑:正如Peter O在下面指出的那样,我在标记中添加了缺少的div标签...将此与验证器使用的标记进行比较表明,这个div虽然存在于标记中显然不值得验证...所以有点将问题改为......为什么忽略那个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 INPUT elements should be placed within a DIV element, like this: INPUT元素应放在DIV元素中,如下所示:

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

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. 在所有可能性中,这很可能是一个错误。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM