visual-studio-2010 - 元素 'tr' 不能嵌套在元素 'tr' 中

标签 visual-studio-2010 asp.net-mvc-3 html validation

我有这样的局部 View :

@model List<user>

@foreach (var user in Model)
{
    <tr>
        <td>@user.name</td>
        <td>...</td>
    </tr>
}

并得到这样的错误:

Validation (HTML5): Element 'tr' cannot be nested within element 'tr'.

这让我很烦,但我想摆脱它。安装 Web Standards Update没有帮助。有什么想法吗?

编辑 这是主视图:

<table>
    <thead>
        <tr>
            <th>@i18n.name</th>
            <th>...</th>
        </tr>
    </thead>
    <tbody id="results">
        @Html.Partial("list_rows", @Model.users)
    </tbody>
</table>

这是生成的 HTML:

<table>
    <thead>
        <tr>
            <th>naam</th>
            <th>...</th>
        </tr>
    </thead>
    <tbody id="results">


<tr>
    <td>...</td>
    <td>...</td>
</tr>
<tr>
    <td>...</td>
    <td>...</td>
</tr>

    </tbody>
</table>

编辑 通过 W3C 验证器拉取整个页面给出

This document was successfully checked as HTML5!

最佳答案

打开 <tr> 时会出现此错误在循环模型之前添加元素。到目前为止,您发布的代码是正确的,没有错误。

关于visual-studio-2010 - 元素 'tr' 不能嵌套在元素 'tr' 中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9785012/

相关文章:

html - 导航栏和下拉栏之间的空间

jquery - Foundation 6 嵌套网格,图像未展开全高

javascript - 一次播放一个 HTML 音频元素

.net - GalaSoft.MvvmLight.WP71 编译错误,需要为 RelayCommand 添加对 System.Windows 的引用

c# - 如何使用 T4 将类从一个项目转换到另一个项目?

asp.net-mvc-3 - 如何将强类型模型作为数据参数传递给jquery ajax post?

asp.net-mvc-3 - 如何在 Razor 中设置隐藏值

c++ - 使用 C++ 的 Win32/MFC 命名约定

c# - Linq:方法无法转换为存储表达式

jquery - 如果用户单击 "Cancel"按钮,Ajax.Actionlink OnBegin 确认不会阻止调用 ajax 调用