use RenderMvcController to filter a list in Umbraco

449 Views Asked by At

my goal is to create a list of contents (of specific docType) . in this list I have a filter button and two ddlist dynamically filled with children data. when user click the "filter" , the list should be updated by selected ddlist values. Is it possible to use RenderMVCController for this ? I couldnt used surfaceController because I cant have access to Index action before rendering the page. Is it possible to use Ajax when user submit the form instead of refreshing all page?

View

using (Html.BeginUmbracoForm("FilterPage", "inTheFieldController", FormMethod.Post, htmlAttributes: new { @id = "PageInTheField" }))
{
//....
}

Controller

public class inTheFieldController : RenderMvcController
{

    private readonly UmbracoContext umbracoContext;

    public inTheFieldController()
    {
        umbracoContext = UmbracoContext.Current;
    }


    // GET: inTheField
    public ActionResult Index()//RenderModel model)
    {
}

and I want to have something like this:

  [HttpPost]
  public ActionResult FilterPage(inTheFieldModel model)
  {
    return null
     }

But it never reached to this point,it asks for surfaceController.

enter image description here

1

There are 1 best solutions below

2
On

Yes, if you use the BeginUmbracoForm it will always expect a SurfaceController. Ideally you should be using SurfaceController for forms. I dont clearly understand what you are trying to do here but you can use @Ajax.BeginForm and couple it with a SurfaceController action