无法将模型绑定到DevExpress按钮的路由值

时间:2018-07-05 13:06:41

标签: c# asp.net-mvc-4 devexpress

我似乎无法从视图中获取模型以使用DevExpress按钮的路由值传递回控制器动作。这是按钮:

Html.DevExpress().Button(btn =>
{
    btn.Name = "btnSubmit";
    btn.Text = "Search";
    btn.Width = Unit.Pixel(100);
    btn.UseSubmitBehavior = true;
    btn.RouteValues = new {Controller = "ProjectSearch", Action = "PerformSearch", projectSearchParametersModel = Model};
}).Render();

然后我要执行此控制器操作:

public ActionResult PerformSearch(IProjectSearchParametersModel projectSearchParametersModel)
{ /* do search */ }

不幸的是,每次我执行该操作时projectSearchParametersModel都为null,我无法弄清楚为什么该模型无法通过。

1 个答案:

答案 0 :(得分:0)

使用:

@using (Html.BeginForm(FormMethod.Post))

示例:

@using (Html.BeginForm(FormMethod.Post))
{
    Html.DevExpress().Button(btn =>
    {
        btn.Name = "btnSubmit";
        btn.Text = "Search";
        btn.Width = Unit.Pixel(100);
        btn.UseSubmitBehavior = true;
        btn.RouteValues = new {Controller = "ProjectSearch", Action = "PerformSearch"};
    }).Render();
}