.NET MVC Ajax.BeginForm在成功或失败结果之前显示消息

时间:2017-06-23 11:22:11

标签: jquery asp.net ajax asp.net-mvc razor

我的.NET MVC应用程序中有一个ajax表单,如下所示:

@using (Ajax.BeginForm("ChangePassword", "User", new { area = "UserSettings" }, new
AjaxOptions
{
   HttpMethod = "POST",
   OnSuccess = "ShowMessage('Password successfully changed')"

}, null))
{
   @Html.TextBoxFor(m => m.Password, new { placeholder = "Password", @class = "form-control", @type = "password" })<br />
   @Html.ValidationMessageFor(model => model.Password, "", new { @class = "text-danger", @style = "float:right;" })
   @Html.TextBoxFor(m => m.PasswordConfirm, new { placeholder = "Confirm password", @class = "form-control", @type = "password" })<br />
   @Html.ValidationMessageFor(model => model.PasswordConfirm, "", new { @class = "text-danger", @style = "float:right;" })
   <button type="submit" class="btn btn-primary">Change Password</button>
}

它本质上是一个更改密码的表单......现在您可以看到我在此表单之外的脚本标记中定义了一个ShowMessage方法,然后我在这里调用...

我的问题是,在此期间服务器处理用户之前&#39;发布请求,并在显示成功或失败消息之前...如何使用此方法在UI中向用户显示内容?

像加载动画或类似的东西?这是可行的,如果是的话,有人可以帮助我吗?

0 个答案:

没有答案