Jquery 未按照post方法在MVC视图中获取更新
未按照post方法在MVC视图中获取更新 嗨 这是我的控制器代码:Jquery 未按照post方法在MVC视图中获取更新,jquery,asp.net-mvc,asp.net-mvc-2,Jquery,Asp.net Mvc,Asp.net Mvc 2,未按照post方法在MVC视图中获取更新 嗨 这是我的控制器代码: public ActionResult Search() { ForecastManagementViewModel viewModel = new ForecastManagementViewModel(); viewModel.JobDate = System.DateTime.Now; return View(viewModel); } [HttpPost] public ActionResul
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>
<% } %>
任何我可能出错的想法。我在VisualStudio2008SP1下使用MVC2
干杯
J Dubs.可能是表单不匹配的问题。。。您能否通过查看源代码检查客户端的ID,以确保它在发布时正确连接到模型?此外,我还将使用post中的断点检查表单集合,以查看服务器端的密钥。表单集合也可以作为控制器的属性使用。嗨,Brian,感谢您这么快就回来了。我已经检查了标记,可以确认使用了正确的名称。我将尝试将这个问题简化为一个小型项目,看看项目的其他部分是否有副作用。同时,欢迎您提出其他建议。我现在创建了一个测试项目并将其压缩。我可以上传到stackoverflow吗?可能是编码形式-它是一个13k的拉链,可以清楚地显示问题。找到答案: