I'm working with ASP.NET MVC, and I'm trying to make changes to the view model after the user has posted it to the server and then send those changes back down to the view.
However, the changes aren't going back to the view except where I'm using Model.<property>
in the Form. The bound Html helpers retain whatever the user typed in. I know I'm missing something obvious, I just can't see it.
View
@model ACE.ViewModels.SecureVM
@using (Html.BeginForm(Model.ActionMethod, Model.Controller, FormMethod.Post))
{
<table>
<tr>
<td>System Name</td>
<td>
@Html.TextBoxFor(model => model.SystemName)
</td>
</tr>
<tr>
<td>User Name</td>
<td>@Html.TextBoxFor(model => model.UserName)</td>
</tr>
<tr>
<td>User First Name</td>
<td>@Html.TextBoxFor(model => model.UserFirstName)</td>
</tr>
<tr>
<td>User Last Name</td>
<td>@Html.TextBoxFor(model => model.UserLastName)</td>
</tr>
</table>
<input type="submit" value="Submit" />
}
Controller
public ActionResult SecureLaunch()
{
var model = new SecureVM();
model.Controller = "LaunchAsCustomer";
model.ActionMethod = "SecureLaunch";
return this.View(model);
}
[HttpPost]
public ActionResult SecureLaunch(SecureVM model)
{
model.UserName = "Bob120";
model.UserFirstName = "Bob";
model.UserLastName = "Jones";
model.Controller = "Test";
model.ActionMethod = "Test";
return this.View(model);
}
This is an example scenario that demonstrates the problem.