DevExpress - Ajax表单返回null对象

时间:2015-01-24 16:24:26

标签: ajax asp.net-mvc devexpress-mvc

我使用Ajax.BeginForm

@model Shared.DataContracts.ConfigurationTransports
@using (Ajax.BeginForm("Save", "ConfigurationTransports",
new AjaxOptions
{
    HttpMethod = "POST",
    InsertionMode = InsertionMode.Replace
}))
{
   Html.RenderPartial("~/Views/ConfigurationTransports/ConfigurationPartialContent.cshtml", Model);
}

我的简单表格

@model Shared.DataContracts.ConfigurationTransports

@Html.DevExpress().Label(s =>
{
    s.Name = "Id";
    s.ClientVisible = false;
}).Bind(Model.Id).GetHtml()


@Html.DevExpress().CheckBox(settings =>
{

settings.Name = "checkBoxUseStop";
settings.Properties.ValueUnchecked = 0;
settings.Properties.ValueChecked = 1;
settings.Text = Resources.UseStops;
}).Bind(Model.UseStop).GetHtml()



@Html.DevExpress().Button(settings =>
 {
 settings.Name = "btnSave";
 settings.UseSubmitBehavior = true;
 }).GetHtml()

当我点击保存帖子到方法保存和参数ConfigurationTransports是空的没有值,但如果我加载我的表单我有我的发送对象的值。

 public ActionResult Save(ConfigurationTransports transport)
    {
        //Some logic method
        return View("Index", preprava.GetData());
    }

我在devexpress论坛上阅读了很多主题,但我找不到解决方案。 你有什么主意吗? THX

1 个答案:

答案 0 :(得分:0)

使用 [HttpPost] 注释

修饰您的Action
[HttpPost]
public ActionResult Save(ConfigurationTransports transport)
{
    //Some logic method
    return View("Index", preprava.GetData());
}