0
我使用asp.net mvc5。我在網站(佈局)的右側面板中創建一個菜單。當用戶點擊菜單項時,無需刷新頁面即可加載頁面。爲此,我使用Ajax.ActionLink
。如何重定向到使用ajax查看?
<aside class="right-panel flexcol">
<button class="accordion">Hotels</button>
<div class="sub-panel flexcol">
@Ajax.ActionLink("View Hotels", "Index", "Hotel", null, new AjaxOptions { HttpMethod = "get", UpdateTargetId = "pageContent" }, new { @class = "sub-menu" })
@Ajax.ActionLink("HotelType", "Index", "HotelType", null, new AjaxOptions { HttpMethod = "get", UpdateTargetId = "pageContent" }, new { @class = "sub-menu" })
</div>
和呼叫'新酒店頁面,我使用
@Ajax.ActionLink("Create Hotel", "Create", "Hotel", null, new AjaxOptions { HttpMethod = "get", UpdateTargetId = "pageContent" }, new { @class = "bluelink" })
這些工作正常。 問題:當我提交創建頁面,此頁面發送給控制器,如果模型填充無效的數據,頁面重定向到創建頁面沒有佈局和css的。
@model ... Models.Hotel
@{
ViewBag.Title = "Create";
Layout =null;
}
控制器
public ActionResult Create()
{
return PartialView();
}
[HttpPost]
public ActionResult Create(Hotel model)
{
if (!ModelState.IsValid)
{
return PartialView(model);
}
ApplyToDataBase(model, "uspInsertHotel");
return RedirectToAction("Index");
}