Feedback on shared view with form submit
I have my main shared view (_Layout) with this:
<div class="slide-out-div">
<a class="handle" href="http://link-for-non-js-users">Content</a>
@{Html.RenderAction("Feedback", "Home");}
</div>
It is a slide panel (works, nothing to worry about) that contains a form. (Feedback.cshtml) That controller/action gets the correct view but when I do the submit, the whole view is updated, and I just want that "RenderAction" to be updated with another view saying "Thank you"
My form (Feedback.cshtml) looks like this:
@model project.FeedbackViewModel
@{
ViewBag.Title = "Feedback";
}
<h2>Feedback</h2>
@using (Html.BeginForm("Feedback", "Home", FormMethod.Post))
{
@Html.ValidationSummary()
<p>User:</p>
<p>@Html.TextBoxFor(m => m.UserName, new { @readonly = "readonly" })</p>
<p>Last Name:</p>
<p>@Html.TextBoxFor(m=>m.UserEmail, new { @readonly = "readonly" })</p>
<p>Message:</p>
<p>@Html.TextAreaFor(m=>m.Description, new { @cols = 80, @rows = 10 })</p>
<input type="submit" value="Submit" />
}
and the Action called:
public ActionResult Feedback() { //blah blah blah
return PartialView(fbVM);
}
[HttpPost]
public ActionResult Feedback(FeedbackViewModel model)
{
if (ModelState.IsValid)
{
//put data in DB
return View("~/Views/Home/FeedbackThanks.cshtml");
}
return View(model);
}
Should I return a PartialView? change the RenderAction? What am I doing wrong?
The get method works. The return View solution gives this error:
Exception Details: System.InsufficientExecutionStackException: Insufficient stack to continue executing the program safely. This can happen from having too many functions on the call stack or function on the stack using too much stack space.
And if I use PartialView instead, the whole page will render the new view instead of just the feedback div.
链接地址: http://www.djcxy.com/p/50948.html上一篇: 嵌套的partialview不刷新
下一篇: 与表单提交共享视图的反馈