How to update model?
- by Alexander Efimov
Hi, guys.
I have an ASP.NET MVC page where the model is being edited.
On each action executing I have a new controller, so I don't get an updated model.
I'm saving a model instance into Session["MyModelKey"]. But every time an action is executed, I have unmodified instance there even if I have changed values in textboxes which were created like this:
@Html.LabelFor(model = model.EMail)
@Html.TextBoxFor(model = model.EMail)
@Html.LabelFor(model = model.Country)
@Html.TextBoxFor(model = model.Country)
@Html.ActionLink("MyAction", "MyController")
Controller:
public class MyController : Controller
{
public ActionResult MyAction()
{
//Every time this action is executed - I have a new controller instance
//So I have null in View.Model
//I get Session["MyModelKey"] here,
//But the model instance properties are not updated
//even though I have updated E-mail and Country properties of the model in the UI
}
}
So, how can I get an updated model?
Thanks in advance.