Thursday 27 June 2013

Updating MVC view based on model updated in code

The following code increments a model property in MVC3 and updates the UI:

[HttpPost]
public ActionResult Edit(Movie model)
{
var temp = model.Age + 1;
ModelState.Remove("Age");
model.Age = temp;

if (ModelState.IsValid)
{
db.Entry(model).State = EntityState.Modified;

db.SaveChanges();
//return RedirectToAction("Index");
}
return View(moviedb2);
}

No comments:

Post a Comment