2016 系统设计第一期 (档案一)MVC 控制器接收表单数据

1.FormCollection collection   user.UserId =Convert.ToInt32(collection["UserId"]); 

/// <summary>
        /// 更新
        /// </summary>
        /// <param name="userId"></param>
        /// <param name="collection"></param>
        /// <returns></returns>
        [HttpPost]
        public ActionResult Edit(FormCollection collection)
        {
            try
            {
                Users user = new Users(); 
                user.UserId =Convert.ToInt32(collection["UserId"]); 

}
}

2.Request.Form["UserId"]

/// <summary>
        /// 更新
        /// </summary>
        /// <param name="userId"></param>
        /// <param name="collection"></param>
        /// <returns></returns>
        [HttpPost]
        public ActionResult Edit(FormCollection collection)
        {
            try
            {
                Users user = new Users();
               user.UserId=Convert.ToInt32(Request.Form["UserId"]); 
            }
}

 

你可能感兴趣的:(2016 系统设计第一期 (档案一)MVC 控制器接收表单数据)