public ActionResult Test2(MyVM data) { if (ModelState.IsValid) { return(RedirectToAction("Index")); } return(View(data)); }
public ActionResult ActionY() { // Update an existing MyVM object. var myVm = new MyVM { Property1 = "Value 1", Property2 = DateTime.Now }; PrepareViewModel(myVm); }
public ActionResult Index() { MyVM vm = new MyVM(); return(View(vm)); //you will have FooDdl available in your views }
public ActionResult ActionX() { // Creates a new MyVM. MyVM myVm = PrepareViewModel(); }
/// <summary> /// Prepares the specified MyVM by filling the common properties. /// </summary> /// <param name="myVm">The MyVM.</param> /// <returns>A MyVM.</returns> protected MyVM PrepareViewModel(MyVM myVm) { myVm.FooDll = GetFooSelectList(); return(myVm); }