Example #1
0
 public ActionResult PostChildViewModel(ChildViewModel vm)
 {
     ViewBag.Action         = "PostChildViewModel";
     ViewBag.ModelType      = vm.GetType().Name;
     ViewBag.BoundModelData = JsonConvert.SerializeObject(vm, Formatting.Indented);
     ViewBag.BoundModel     = vm;
     return(View("ChangingContext"));
 }
 public ActionResult PostChildViewModel(ChildViewModel vm, bool tagHelpers)
 {
     ViewBag.Action         = "PostChildViewModel";
     ViewBag.ModelType      = vm.GetType().Name;
     ViewBag.BoundModelData = JsonSerializer.Serialize(vm, new JsonSerializerOptions {
         WriteIndented = true
     });
     ViewBag.BoundModel = vm;
     return(View(tagHelpers ? "ChangingContextTH" : "ChangingContext"));
 }
 public ViewModelExample()
 {
     // This could be set using a model binder if it's populated from a database or similar
     List = new List <ListItem> {
         new ListItem {
             Id = 1, Name = "A"
         }, new ListItem {
             Id = 2, Name = "B"
         }
     };
     DecimalWithFormatStringAttribute = 1.2300m;
     Decimal = 1.2300m;
     Child   = new ChildViewModel();
 }
 public ViewModelExample()
 {
     // This could be set using a model binder if it's populated from a database or similar
     List = new List<ListItem> {new ListItem{Id = 1, Name = "A"}, new ListItem{Id = 2, Name = "B"}};
     DecimalWithFormatStringAttribute = 1.2300m;
     Decimal = 1.2300m;
     Child = new ChildViewModel();
 }
 public ActionResult PostChildViewModel(ChildViewModel vm)
 {
     ViewBag.Action = "PostChildViewModel";
     ViewBag.ModelType = vm.GetType().Name;
     ViewBag.BoundModelData = JsonConvert.SerializeObject(vm, Formatting.Indented);
     ViewBag.BoundModel = vm;
     return View("ChangingContext");
 }