Not getting updates in MVC View following a post method
Hi,
Here's my controller code:
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);
}
The problem is that when the new view is returned it doesn't contain the updated date value. (By the way, there's a jquery EditorTemplate behind this DateTime type).
Here's a bit of the view code:
<% 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>
<% } %>
Any ideas where I might be going wrong. I'm using MVC2 under Visual Studio 2008 SP1.
Cheers,
J Dubs.