0
在MVC视图没有得到更新,以下POST方法没有得到以下POST方法
嗨,
这里是我的控制器代码在MVC视图更新:
public ActionResult Search()
{
ForecastManagementViewModel viewModel = new ForecastManagementViewModel();
viewModel.JobDate = System.DateTime.Now;
return View(viewModel);
}
[HttpPost]
public ActionResult Search(ForecastManagementViewModelPost model)
{
ForecastManagementViewModel viewModel = new ForecastManagementViewModel();
viewModel.JobDate = model.JobDate.AddDays(20);
return View(viewModel);
}
的问题是,当新视图返回它不包含更新的日期值。 (顺便说一下,这个DateTime类型后面有一个jQuery EditorTemplate)。
这里有点视图代码:
<% using (Html.BeginForm())
{ %>
<fieldset>
<legend>Search Criteria</legend>
<div class="divFirstColumn">
<div><%= Html.LabelFor(m => m.JobDate) %></div>
<%= Html.EditorFor(m => m.JobDate) %>
</div>
</fieldset>
<% } %>
,我可能会错误的任何想法。我在Visual Studio 2008 SP1下使用MVC2。
干杯,
J Dubs。
嗨,布莱恩,谢谢你回来这么快。我检查了标记并可以确认正在使用正确的名称。我会尝试将问题简化为一个小型项目,以查看项目其余部分是否存在一些副作用。同时,欢迎其他建议。 – dubs 2010-09-15 14:05:08
我现在已经创建了一个测试项目并将其压缩。我可以上传到stackoverflow?也许是编码形式 - 这是一个13k的zip文件,可以清楚地显示问题。 – dubs 2010-09-15 14:43:39
找到答案:http://blogs.msdn.com/b/simonince/archive/2010/05/05/asp-net-mvc-s-html-helpers-render-the-wrong-value.aspx – dubs 2010-09-15 15:26:58