Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
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:
return PartialView("StaffDirectoryServiceList", model);
The this partial view I am rendering a form:
@using (Html.BeginUmbracoForm<Hub2.Controllers.StaffDirectorySurfaceController>("StaffSearch", FormMethod.Post))
@Html.TextBoxFor(m => m.staffQuery)
<input type="submit" value="* Search *" />
In the surface controller I have this, just really simple for now:
public ActionResult StaffSearch(StaffDirectoryViewModel model, String staffQuery)
String searchWords = staffQuery.Split(' ');
model.staffList = new List<MemberOfStaff>();
return PartialView("StaffDirectoryStaffList", model);
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?
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 ?
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.
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
is working on a reply...
Write your reply to:
Image will be uploaded when post is submitted