2014-10-21 43 views
0

创建控制器索引/编辑/创建/删除视图时,生成了一个标准编辑表单。其中一个字段是一个日期,所以我添加了一个Telerik演示(主要用于播放),并且希望为该字段使用日期选择器。将Telerik日期选取器值传递给控制器​​

原始代码是:

<div class="form-group"> 
    @Html.LabelFor(model => model.InstallDate, htmlAttributes: new { @class = "control-label col-md-2" }) 
    <div class="col-md-10"> 
     @Html.EditorFor(model => model.InstallDate, new { htmlAttributes = new { @class = "form-control" } }) 
     @Html.ValidationMessageFor(model => model.InstallDate, "", new { @class = "text-danger" }) 
    </div> 
</div> 

我已经更改为:

<div class="form-group"> 
      @Html.LabelFor(model => model.InstallDate, htmlAttributes: new { @class = "control-label col-md-2" }) 
      <div class="col-md-10"> 
       @(Html.Kendo().DatePicker() 
       .Name("datepicker") 
       .Value(Model.InstallDate) 
       .HtmlAttributes(new { style = "width:150px" }) 
       ) 
       @Html.ValidationMessageFor(model => model.InstallDate, "", new { @class = "text-danger" }) 
      </div> 
     </div> 

日期选择器呈现的文件,但是我无法弄清楚如何通过价值挑回控制器,所以它可以保存。

如何保存日期选择器值?

回答

0

进行研究,发现我使用错误的函数调用。 。相反的DatePicker()全部使用@(Html.Kendo()其实,我需要做的是改变:

@Html.EditorFor(model => model.InstallDate, new { htmlAttributes = new { @class = "form-control" } }) 

@Html.Kendo().DatePickerFor(model => model.InstallDate) 
相关问题