using ajax form inside helper method

151 Views Asked by At

How do you use a mvc helper method to create a ajax.beginform?

for ex:

@helper AjaxForm(string action, string controller, object routevalues, AjaxOptions options, params MvcHtmlString[] fields)
{
    // DOES NOT WORK
    @using(Ajax.BeginForm(action, controller, routevalues, options))
    {
        foreach (var field in inputfields)
        {
            @field
        }  
    }
}

I would like to use this field anywhere in my views like this

@helper AjaxForm("Action", "Controller", new {id = "1"}, new AjaxOptions())
1

There are 1 best solutions below

1
On

Like this

@using (Html.BeginForm())
{


}