我在CSS中创建了一个错误类。发出GET请求时,视图将在客户端呈现,但会显示错误类。我想在发出GET请求时隐藏错误类,并在发出POST请求时显示它。 请参见下图:
我的cshtml标记
<div class="row">
<div class="col-md-4 col-md-offset-4 col-sm-6 col-sm-offset-3">
@using (Html.BeginForm("ExternalSignIn", "Account", new { ReturnUrl = returnUrl }, FormMethod.Post, new { @class = "reg-page" }))
{
@Html.ValidationSummary(true, "", new { @class = "text-danger" })
<input id="xss" type="hidden" name="idsrv.xsrf" token="model.antiForgery">
<div class="reg-header">
<h2>Login to your account</h2>
</div>
<div class="alert alert-danger">
@Html.ValidationMessageFor(model => model.Email)
</div>
<div class="input-group margin-bottom-20">
<span class="input-group-addon"><i class="fa fa-user"></i></span>
@Html.EditorFor(model => model.Email, new { htmlAttributes = new { @class = "form-control", id = "username", type = "email", required = "required", placeholder = "Email", name = "username" } })
</div>
<div class="row">
<div class="col-md-6 checkbox login-remember">
<label><input type="checkbox" id="rememberMe" name="rememberMe" value=""> Stay signed in</label>
</div>
<div class="col-md-6">
<button btn-primaryng-disabled="form.$invalid" class="btn-u pull-right" type="submit">Login</button>
</div>
</div>
<hr>
<h4>Forget your Password ?</h4>
<p>
no worries, <a class="color-green" href="">click here</a> to reset your password.
</p>
}
</div>
</div><!--/row-->