Return PartialView from SurfaceController ActionResult
Hi,
I'm creating a SurfaceController along with some partial views to perform a simple search of some external data.
The Index ActionResult is fine, returns a partial view with the search form with some info, and is complete with the template, I am returning from the Index result like this:
I'm not using Ajax here, have done in the past on another site, it's an option that I could use but would prefer not to in this case.
I did try using return CurrentUmbracoPage in the StaffSearch ActionResult but found that returns the partial view from the Index ActionResult & the Model is not updated.
Your return from a controller has to be a view, and if you are only wanting part of the page to be updated, then you will need to use AJAX.
So if not using AJAX the only true option is to have a view with a custom view model (including search results) and then if necessary pass part of the view model to the partial.
Return PartialView from SurfaceController ActionResult
Hi,
I'm creating a SurfaceController along with some partial views to perform a simple search of some external data.
The Index ActionResult is fine, returns a partial view with the search form with some info, and is complete with the template, I am returning from the Index result like this:
The this partial view I am rendering a form:
In the surface controller I have this, just really simple for now:
This code is working, but when it returns it is literally just the partial view, it no longer has template for the page.
How can I get this to return with the template?
Mike
Hi Mike
Are you using AJAX for posting to the controller and trying to get the partial view back, or are you posting directly to the Controller ?
Nigel
I could be wrong but BeginUmbracoForm should return a View, CurrentUmbracoPage, or something similar.
If you want a partial view, try using one of the Ajax.BeginForm() overloads calling into a surfacecontroller.
Hi Nigel & John, thanks for your replies.
I'm not using Ajax here, have done in the past on another site, it's an option that I could use but would prefer not to in this case.
I did try using return CurrentUmbracoPage in the StaffSearch ActionResult but found that returns the partial view from the Index ActionResult & the Model is not updated.
Hi Mike
Your return from a controller has to be a view, and if you are only wanting part of the page to be updated, then you will need to use AJAX.
So if not using AJAX the only true option is to have a view with a custom view model (including search results) and then if necessary pass part of the view model to the partial.
Hope this helps
Nigel
is working on a reply...