var childWindow = $("#editFrame")[0].contentWindow;//获取子窗体的window对象.
childWindow.subForm();
$("#editFrame")得到frame
[0].contentWindow//frame的子窗体,将JQUERY对象转化为DOM对象
subForm();//字窗体定义的方法
-----------------------------------------------------
子窗体调用父窗体的方法
function afterEdit(data) {
if (data == "ok") {
window.parent.afterEdit(data);
}
}
-------------------------------------
@model CZBK.ItcastOA.Model.RoleInfo @{ Layout = null; } <!DOCTYPE html> <html> <head> <meta name="viewport" content="width=device-width" /> <title>编辑角色信息</title> <script src="~/Scripts/jquery-1.7.1.min.js"></script> <script src="~/Scripts/jquery.unobtrusive-ajax.min.js"></script> <script type="text/javascript"> function subForm() { $("#editForm").submit(); } function afterEdit(data) { if (data == "ok") { window.parent.afterEdit(data); } } </script> </head> <body> @using (Ajax.BeginForm("EditRoleInfo", "RoleInfo", new { }, new AjaxOptions() { HttpMethod = "post", OnSuccess = "afterEdit" }, new {})) { @Html.ValidationSummary(true) <fieldset> <legend>RoleInfo</legend> @Html.HiddenFor(model => model.ID) <div class="editor-label"> @Html.LabelFor(model => model.RoleName, "角色名称") </div> <div class="editor-field"> @Html.EditorFor(model => model.RoleName) @Html.ValidationMessageFor(model => model.RoleName) </div> <div class="editor-label"> @Html.LabelFor(model => model.DelFlag) </div> <div class="editor-field"> @Html.EditorFor(model => model.DelFlag) @Html.ValidationMessageFor(model => model.DelFlag) </div> <div class="editor-label"> @Html.LabelFor(model => model.SubTime) </div> <div class="editor-field"> @Html.EditorFor(model => model.SubTime) @Html.ValidationMessageFor(model => model.SubTime) </div> <div class="editor-label"> @Html.LabelFor(model => model.Remark) </div> <div class="editor-field"> @Html.EditorFor(model => model.Remark) @Html.ValidationMessageFor(model => model.Remark) </div> <div class="editor-label"> @Html.LabelFor(model => model.ModifiedOn) </div> <div class="editor-field"> @Html.EditorFor(model => model.ModifiedOn) @Html.ValidationMessageFor(model => model.ModifiedOn) </div> <div class="editor-label"> @Html.LabelFor(model => model.Sort) </div> <div class="editor-field"> @Html.EditorFor(model => model.Sort) @Html.ValidationMessageFor(model => model.Sort) </div> </fieldset> } <div> @Html.ActionLink("Back to List", "Index") </div> </body> </html>