【发布时间】:2014-03-27 03:57:11
【问题描述】:
我正在使用ViewBag 作为我的检查点,我应该在某个 div 上呈现partial view,这是我的代码:
在控制器中:
[HttpPost]
public ActionResult NewAppointment(appointment.AppointmentInformation model)
{
if (ViewBag.NextForm == null || ViewBag.NextForm == "undefined")
{
info.CustomerType = model.CustomerType;
ViewBag.NextForm = "Information";
}
else if (ViewBag.NextForm == "Information")
{
info.CustomerID = String.IsNullOrEmpty(model.CustomerID) ? "" : model.CustomerID;
info.CustomerName = String.IsNullOrEmpty(model.CustomerName) ? "" : model.CustomerName;
info.CustomerCNum = String.IsNullOrEmpty(model.CustomerCNum) ? "" : model.CustomerCNum;
ViewBag.NextForm = "Services";
}
else if (ViewBag.NextForm == "Services")
{
//do nothing;
}
return View(info);
}
在视图中:
<form method="post">
<div id="PartialContainer">
@if (ViewBag.NextForm == null || ViewBag.NextForm == "undefined")
{
@Html.Partial("CustomerType")
}
@if (ViewBag.NextForm == "Information")
{
@Html.Partial("GuestInformation")
}
@if (ViewBag.NextForm == "Services")
{
@Html.Partial("Service")
}
</div>
<div id="ButtonArea">
<button id="btnCancel">Cancel</button>
<button id="btnBack">Back</button>
<button id="btnNext">Next</button>
</div>
第三次点击btnNext,@Html.Part @Html.Partial("Service") 不起作用。但前两个@Html.Partial 工作正常..
我的代码有什么问题?
【问题讨论】:
标签: asp.net-mvc asp.net-mvc-4 razor