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