Wonder if someone could help me out here......
Basically what I'm trying to do if on the posting of a form, I'm doing some custom validation and if the data being submitted doesn't conform to the business then I'd like to stop processing (obviously!) and pass the incoming model back to the view that contains the form so that the user doesn't have to re-key all of their data.
The way that I'm set this up is (This is using Umbraco as a CMS):
1) I've created the model/properties. 2) I've then created a strongly-typed partial view and selected the model class that I'd just created (named AwardsCeremony) 3) I've then created a controller with the following Index ActionResult:
public ActionResult Index()
{
TempData["priceList"] = getPrices();
TempData["qualificationList"] = getQualifications();
return PartialView("AwardsCeremony", new AwardsCeremonyViewModel());
}
4) Then in the Umbraco template I'm calling the controller
@Html.Action("Index", "AwardsCeremonySurface")
(this umbraco inherits it's styling, etc from the Master template (in Umbraco)).
In the view (on the HTTPPOST event) I'm calling the processBooking actionresult on the controller.
@using (Html.BeginUmbracoForm("processBooking", "AwardsCeremonySurface", null, new { @class = "form-horizontal" }))
This ActionResult then does the error checking and that's where the problems start (!), I've removed my custom validation for ease of reading.
[HttpPost]
public ActionResult processBooking(AwardsCeremonyViewModel model)
{
//Do the custom error handling
if (myInvalidForm == true)
{
return PartialView("AwardsCeremony",model);
}
//Process the booking
return RedirectToCurrentUmbracoPage();
}
What's happening is that when the partial view is returned back the styling of the page is lost, the form displayed but with none of the inherited styling, classes, etc from the Umbraco Master template and I just don't know how to fix. Could someone point me in the right direction please?
Thanks, Craig