0
我不知道什麼是錯的。 我跟着這個鏈接http://www.dotnetcodesg.com/Article/UploadFile/2/286/CRUD%20operation%20using%20Modal%20Popup%20in%20ASP.NET%20MVC%204.aspx因爲需要幾乎相同的東西:CRUD網格彈出編輯。jQuery對話框彈出窗口顯示在同一個窗口
我做了VS2013生成的HomeController和Index.cshtml中的所有內容。
我從代碼削減所涉及的事情:
Index.cshtml
grid.Column("", header: "Actions",
format: @<text>
@Html.ActionLink("Edit", "EditConstruct", new { id = item.Id, @class = "editDialog" })
<div id="dialog-edit" style="display: none">
控制器
public ActionResult EditConstruct(int id)
{
var data = advConstructRepository.Get(id);
AdvConstructModel model = new AdvConstructModel
{
Id = data.Id,
Description = data.Description,
MaintenanceTime = data.MaintenanceTime,
Location = data.Location,
Height = data.Height,
Width = data.Width,
MonthlyCost = data.MonthlyCost,
AdvConstructType = advConstructRepository.GetAdvConstructType(data.AdvTypeId)
};
ViewBag.IsUpdate = true;
return View("EditConstruct", model);
}
,編輯,查看
@model AdvApplication.Models.AdvConstructModel
@{
Layout = null;
}
<script src="~/Scripts/jquery-1.8.2.min.js"></script>
<script src="~/Scripts/jquery.validate.min.js"></script>
<script src="~/Scripts/jquery.validate.unobtrusive.min.js"></script>
@using (Html.BeginForm("UpdateConstruct", "Home", "POST"))
{
@Html.ValidationSummary(true)
ViewBag.IsUpdate = true;
return View("EditConstruct", model);
}
etc...
但是,當我點擊編輯動作,我收到編輯字段,但不是在彈出窗口中,而是在整個屏幕上作爲單個頁面。 EditConstruct視圖是作爲局部視圖創建的。
請建議如何解決