将HTML类添加到Ajax.RouteForm

时间:2016-05-29 12:56:00

标签: asp.net-mvc

我有一个Ajax.Routeform,其systax给出为:`

@using (Ajax.BeginRouteForm("Contact", new AjaxOptions { HttpMethod =  "POST", OnSuccess = "emailSuccess", OnFailure = "emailFailure" })) 
{
}

我需要在其中添加一个“form-horizo​​ntal”的html类。我怎样才能做到这一点?
包含html属性的方法重载是

Ajax.Routeform( string routeName, object routeValues,  AjaxOptions ajaxOptions, object htmlAttributes )

`

1 个答案:

答案 0 :(得分:0)

htmlAttributes的方法重载是

Ajax.Routeform( string routeName, object routeValues,  AjaxOptions ajaxOptions, object htmlAttributes )

由于不需要routeValues,我可以在其中传递null并且语法非常直接

@using (Ajax.BeginRouteForm("Contact", null, new AjaxOptions { ... }, new { @class = "form-horizontal" }))