0
我正在使用MVC5。我有一個稱爲部分視圖的視圖。局部視圖ajax.beginform onsuccess函數錯誤未定義
關於部分視圖,我有一個Ajax.BeginForm
即OnSuccess
調用函數。
我有一個執行時間錯誤,說該函數沒有finder。
如果函數是在父視圖中定義的,則它被查找並觸發。
這是我的局部視圖
@model TableAvivaVoz.Models.UserPasswordView
<script src="/Scripts/jquery.validate.js"></script>
<script src="/Scripts/jquery.validate.unobtrusive.js"></script>
<script src="/Scripts/jquery.unobtrusive-ajax.js"></script>
@{
ViewBag.Title = "Actualizar";
AjaxOptions ajaxOpts = new AjaxOptions
{
InsertionMode = InsertionMode.Replace,
HttpMethod = "POST",
OnSuccess = "exito",
// OnFailure ="failure",
};
}
@section Scripts {
<script type="text/javascript">
function exito(result) {
alert(1);
}
</script>
}
@using (Ajax.BeginForm("ChangePassword", "Users", ajaxOpts, new { id = "FormID" }))
{
@Html.AntiForgeryToken()
"modal-header">
<h4 class="modal-title" id="myModalLabel">
Cambio de Contraseña
</h4>
</div>
<div class="alert alert-success hidden">
Success! Password Changed.
</div>
@Html.HiddenFor(model => model.User_id)
@Html.ValidationSummary(true, "", new { @class = "text-danger" })
<div class="modal-body">
<div class="col-md-10">
@Html.PasswordFor(model => model.OldPassword, new { @class = "form-control", placeholder = "Vieja Contraseña" })
@Html.ValidationMessageFor(model => model.OldPassword, "", new { @class = "text-danger" })
</div>
</div>
<div class="modal-body">
<div class="col-md-10">
@Html.PasswordFor(model => model.Password, new { @class = "form-control", placeholder = "Nueva Contraseña" })
@Html.ValidationMessageFor(model => model.Password, "", new { @class = "text-danger" })
</div>
</div>
<div class="modal-body">
<div class="col-md-10">
@Html.PasswordFor(model => model.ConfirmPassword, new { @class = "form-control", placeholder = "Repetir Nueva Contraseña" })
@Html.ValidationMessageFor(model => model.ConfirmPassword, "", new { @class = "text-danger" })
</div>
</div>
<div class="modal-footer visible">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
<button type="submit" class="btn btn-primary" id="btnSave">Save</button>
</div>
<div class="modal-footer hidden">
<button type="button" class="btn btn-default" data-dismiss="modal">Salir</button>
</div>
</div><!-- /.modal-content -->
</div><!-- /.modal -->
}
我所缺少的調用從局部視圖功能?
謝謝
好吧,它發生了,我雖然我有一個錯誤。所以我不能在我的ParentView上定義我的OnSucess方法? – Diego