ActionResult SaveEmployee2([ModelBinder(typeof(MyEmployeeModelBinder))]Employee e, string BtnSubmit)
来源:互联网 发布:淘宝图书 编辑:程序博客网 时间:2024/05/16 01:04
SaveEmployee2
<div>
<form action="/Employee/SaveEmployee2" method="post">
FName: <input type="text" id="tFName" name="FName" value="" /><br />
LName: <input type="text" id="tLName" name="LName" value="" /><br />
Salary: <input type="text" id="tSalary" name="Salary" value="" /><br />
<input type="submit" name="BtnSubmit" value="Save Employee" />
</form>
</div>
public class MyEmployeeModelBinder : DefaultModelBinder
{
protected override object CreateModel(ControllerContext controllerContext, ModelBindingContext bindingContext, Type modelType)
{
Employee e = new Employee();
e.FirstName = controllerContext.RequestContext.HttpContext.Request.Form["FName"];
e.LastName = controllerContext.RequestContext.HttpContext.Request.Form["LName"];
e.Salary = int.Parse(controllerContext.RequestContext.HttpContext.Request.Form["Salary"]);
return e;
}
}
public ActionResult SaveEmployee2([ModelBinder(typeof(MyEmployeeModelBinder))]Employee e, string BtnSubmit)
{
return Content(e.FirstName + "|" + e.LastName + "|" + e.Salary);
}
- ActionResult SaveEmployee2([ModelBinder(typeof(MyEmployeeModelBinder))]Employee e, string BtnSubmit)
- Employee SaveEmployee(Employee e)
- MVC4 ViewResult String ActionResult 区别
- 使用jquery传递复杂Json数据——[ModelBinder(typeof(JsonBinder<复杂实体类>))]
- ActionResult
- employee
- Employee
- typeof
- typeof
- typeof
- typeof
- typeof
- typeof
- typeof
- typeof
- typeof
- typeof
- typeof
- 使用Objective-C创建UUID
- Python3,命令交互式,无法使用退格键、方向键
- java日志组件介绍(common-logging,log4j,slf4j,logback )
- oracle 11g rac 下安装em出错的一些解决方法
- Struts2的执行流程全图
- ActionResult SaveEmployee2([ModelBinder(typeof(MyEmployeeModelBinder))]Employee e, string BtnSubmit)
- Android N 行为变更---Home ---Android ---Nougat
- C++ 学习笔记(三):面向对象编程:类,对象,继承,重载
- 新浪第三方登录
- 单项散列加密
- Realm学习
- 基于自适应PSO 的RBF网络分类算法实现
- MySQL的锁机制
- SpringMVC详解