I am using a ViewBag
as my checkpoint to which partial view
should I render on a certain div and here's my code:
In Controller:
[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);
}
In View:
<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>
On third click of btnNext
, the @Html.Part @Html.Partial("Service")
is not working. But the first two @Html.Partial
is working fine..
What's wrong with my code?