0
我使用EditorTemplate
对于Html.EditorForModel()
当使用没有EditorTemplate
时,验证有效。 没有EditorTemplate
- 验证不起作用。MVC - 使用EditorTemplate和EditorForModel时,模型验证不会触发
这是我的方式:
<div style="padding-top: 20px;">
@using (Html.BeginForm())
{
@Html.EditorForModel()
}
</div>
这是EditorTemplate:
<div style="margin: 0px auto; text-align: center; display: table;">
<table>
<tr>
<td>@Html.EditorFor(x => x.UserName, new { htmlAttributes = new { placeholder = "username" } })</td>
</tr>
<tr>
<td>@Html.EditorFor(x => x.Password, new { htmlAttributes = new { placeholder = "password" } })</td>
</tr>
<tr style="height:70px;">
<td><input type="submit" class="k-primary" value="Log In" /></td>
</tr>
</table>
</div>
我缺少什么?
出于纯粹的好奇,有没有您使用的是EditorForModel与EditorTemplate的理由,而不是直接插入EditorTemplate的内容在形式? – sleeyuen
没有理由。只是为了自我教育的目的:) – gene
好,够公平! – sleeyuen