摘要:
把视图省、市、街道表单数据,封装成一个类,作为action参数。如下: action方法参数类型: namespace MvcApplication1.Models{ public class Customer { public string Address { get; set; } }} 在自定义ModelBinder中,接收视图表单数据,封装成Customer类。 using Syste... 阅读全文
posted @ 2014-05-27 23:38
Darren Ji
阅读(1002)
评论(0)
推荐(0)
摘要:
□ ValueProvider的大致工作原理 →通过Request.Form, Request.QueryString, Request.Files, RouteData.Values获取数据。→然后把数据提供给Model Binder。 public interface IValueProvider{ bool ContainsPrefix(string prefix); Value... 阅读全文
posted @ 2014-05-27 22:53
Darren Ji
阅读(4323)
评论(0)
推荐(1)
摘要:
比如,有这样一个类: public class User { public string Name { get; set; } } 当在强类型视图页,显示属性Name对应的input元素,并想添加一个title属性和对应的值,如图: □ 思路 →自定义TooltipAttribute,可以打到Name属性上。→自定义DataAnnotationsModelMetadataProvider,... 阅读全文
posted @ 2014-05-27 19:01
Darren Ji
阅读(1246)
评论(1)
推荐(2)
摘要:
在Product类中有一个显示删除状态的属性DelFlag,在编辑视图页,对于所有的删除状态以RadioButtonList显示出来,如果RadioButtonList选项的value值与当前model的DelFlag属性值相同,则勾选该选项,如图: 思路: →在Views/Shared/EditorTemplates/RadioButtonList.chtml部分视图以RadioButton... 阅读全文
posted @ 2014-05-27 16:14
Darren Ji
阅读(2197)
评论(0)
推荐(1)
摘要:
实现的效果为:在编辑视图中,对DateTime类型的属性,显示jQuery UI的datepicker。效果如下: Student.cs public class Student { public int Id { get; set; } public string Name { get; set; } public DateTime? JoinTime { get; set; } } Ho... 阅读全文
posted @ 2014-05-27 12:39
Darren Ji
阅读(982)
评论(0)
推荐(1)
摘要:
与ActionFilter相关的接口有2个: □ IActionFilter 对action执行前后处理 void OnActionExecuting(ActionExecutingContext filterContext);可以在此对请求处理,甚至开启一个新的请求。 void OnActionExecuted(ActonExecutedContext filterContext);可以在此... 阅读全文
posted @ 2014-05-27 11:12
Darren Ji
阅读(1288)
评论(0)
推荐(0)
摘要:
□ 接口 public interface IExceptionFilter{ void OnException(ExceptionContext filterContext);} ExceptionContext继承于ControllerContext,从中可以获得路由数据route data、HttpContext。 □ 的HandleErrorAttribute是对IExceptionFi... 阅读全文
posted @ 2014-05-27 00:51
Darren Ji
阅读(2746)
评论(2)
推荐(2)
浙公网安备 33010602011771号