【发布时间】:2015-05-26 11:59:24
【问题描述】:
我有一个表单,它是布局页面中的部分视图。我需要在成功后首先呈现另一个局部视图。
但是,局部视图在第一个局部视图内呈现。 (例如,如果用户在 Mydomain/index 中填写表单,新的局部视图应该显示在相同的 url 中。现在它显示在 /controller/create 中)。
[ChildActionOnly]
public ActionResult Create()
{
ViewBag.SubjectId = new SelectList(db.subjects, "SubjectId", "Subjectname");
return PartialView();
}
[HttpPost]
[ValidateAntiForgeryToken]
public ActionResult Create([Bind(Include = "InfoId,FirstName,SureName,PhoneNumber,Address,Email,EnterdDate,IsActive,Tipol,SubjectId")] Info info)
{
info.EnterdDate = DateTime.Now;
info.IsActive = false;
if (ModelState.IsValid)
{
db.infos.Add(info);
db.SaveChanges();
TempData["thanks"] = info.FullName;
return PartialView("_bla");
}
ViewBag.SubjectId = new SelectList(db.subjects, "SubjectId", "Subjectname", info.SubjectId);
return View(info);
}
public PartialViewResult _bla()
{
var thanks = TempData["thanks"];
return PartialView();
}
【问题讨论】:
标签: asp.net-mvc razor