How To Return View For Parent Page (With ModelStateError) From Partial View Submit?
Dear Umbracians,
I have multiple pages of document type LandingPage. These landing pages include a MemberAddressForm, which is a partial view for requesting some information from people signing up.
This partial view submits to my MemberAddressFormController, the controller for my MemberAddressForm partial view.
In MemberAddressForm.Submit, I am unable to return CurrentUmbracoPage. I get a routing exception, because this method call comes from a partial view, rather than the partial view's parent page.
I want to set a ModelState error message. I have to return a view in order to be able to use this ModelState error message in my view.
I am asking myself how to return the current (parent) page as a view. I can not simply do...
return View("/Views/LandingPage.cshtml")
... because this is a template.
Returning the current template as a View can't work because it is unknown which content page the template needs to be applied to.
I understandably get the following error:
Cannot return the IPublishedContent because the UmbracoHelper was constructed with an UmbracoContext and the current request is not a front-end request.
Here is the code in my MemberAddressFormController:
private ActionResult Submit(User newUser, int pageID)
{
if (!ModelState.IsValid)
{
ModelState.AddModelError("ModelStateInvalid", "Model state isn't valid.");
return Redirect(this.Request.UrlReferrer.ToString()); // how to redirect to parent page as view with useable modelstate error?
}
}
I need to know how to:
Set a ModelState error in a submit action initiated by a partial view.
Return a view to the parent page of the partial view that initiated this submit action.
Maintain the url query string that the user used when visiting the parent page in the first place.
How To Return View For Parent Page (With ModelStateError) From Partial View Submit?
Dear Umbracians,
I have multiple pages of document type LandingPage. These landing pages include a MemberAddressForm, which is a partial view for requesting some information from people signing up.
This partial view submits to my MemberAddressFormController, the controller for my MemberAddressForm partial view.
In MemberAddressForm.Submit, I am unable to return CurrentUmbracoPage. I get a routing exception, because this method call comes from a partial view, rather than the partial view's parent page.
I want to set a ModelState error message. I have to return a view in order to be able to use this ModelState error message in my view.
I am asking myself how to return the current (parent) page as a view. I can not simply do...
... because this is a template.
Returning the current template as a View can't work because it is unknown which content page the template needs to be applied to.
I understandably get the following error:
Here is the code in my MemberAddressFormController:
I need to know how to:
What is the best practice for this?
Anybody know how to do this?
How do I return an UmbracoPage View from a post method Submit, initiated by a MemberAddressForm partial view?
I'm currently using redirects. I want to use views.
Is this even possible ?
is working on a reply...