Example #1
0
        public ActionResult Test2(MyVM data)
        {
            if (ModelState.IsValid)
            {
                return(RedirectToAction("Index"));
            }

            return(View(data));
        }
Example #2
0
    public ActionResult ActionY()
    {
        // Update an existing MyVM object.
        var myVm = new MyVM
        {
            Property1 = "Value 1",
            Property2 = DateTime.Now
        };

        PrepareViewModel(myVm);
    }
Example #3
0
    public ActionResult Index()
    {
        MyVM vm = new MyVM();

        return(View(vm));      //you will have FooDdl available in your views
    }
Example #4
0
 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);
    }