示例#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);
 }