public ActionResult FormCollection(FormCollection collection) { Person person = new Person(); person.Prename = collection["Prename"]; person.Surname = collection["Surname"]; person.Age = int.Parse(collection["Age"]); return View("Result", person); }
public ActionResult ParameterMatching(string Prename, string Surname, int Age) { Person person = new Person(); person.Prename = Prename; person.Surname = Surname; person.Age = Age; return View("Result", person); }
public object BindModel(ControllerContext controllerContext, ModelBindingContext bindingContext) { if (controllerContext == null) { throw new ArgumentNullException("controllerContext"); } if (bindingContext == null) { throw new ArgumentNullException("bindingContext"); } NameValueCollection collection = controllerContext.RequestContext.HttpContext.Request.Form; Person returnValue = new Person(); returnValue.Id = Guid.NewGuid(); returnValue.Prename = "Modelbinder: " + collection["Prename"]; returnValue.Surname = "Modelbinder: " + collection["Surname"]; int age = 0; int.TryParse(collection["Age"], out age); returnValue.Age = age; return returnValue; }
public ActionResult DefaultBinding(Person person) { return View("Result", person); }