예제 #1
0
 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);
 }
예제 #2
0
        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);
        }
예제 #3
0
        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;
        }
예제 #4
0
 public ActionResult DefaultBinding(Person person)
 {
     return View("Result", person);
 }