1
我在頁面上有2個驗證表單。2驗證組
<div id='LogOn' style="background-color: White;">
@using (Ajax.BeginForm("LogOnAjax", "Home", new AjaxOptions { UpdateTargetId = "LogOn", OnSuccess = "logInComplete" }))
{
//ITW2012Mobile.ViewModels.LogOnModel m = Model;
@Html.HiddenFor(model => model.IsLoggedIn)
@Html.HiddenFor(model => model.ReturnUrl)
<div>
@Html.ValidationSummary()
</div>
<div>
@Html.LabelFor(model => model.UserName)
@Html.EditorFor(model => model.UserName)
</div>
<div>
@Html.LabelFor(model => model.Password)
@Html.EditorFor(model => model.Password)
</div>
<div>
<input type="submit" value="Login" />
</div>
}
</div>
和
<fieldset>
@using (Html.BeginForm(Model.ActionMethod, Model.Controller))
{
@Html.ValidationSummary()
.....
<div class="display-label"> E-mail Address * </div>
<div class="display-field">
@Html.EditorFor(model => model.Username)
@Html.ValidationMessageFor(model => model.Username)
</div>
<div class="display-label"> Create Password * </div>
<div class="display-field">
@Html.PasswordFor(model => model.Password)
@Html.ValidationMessageFor(model => model.Password)
</div>
<p>
<input type="submit" value="Create" />
</p>
}
</fieldset>
我如何可以標記ModelState.AddModelError
是第一種形式,因爲我看到了同樣的錯誤在validation summary
兩個地方呢?
但我需要在這兩個地方驗證摘要。存在解決方案嗎? – John
@John。不。抱歉。 **: - (** – gdoron
@John。你可以用你想要的邏輯做你自己定製的'驗證總結''HtmlHelper'。 – gdoron