随笔分类 -  MVC3

获取请求的controller,action的名称,以及parameter的值
摘要:获取控制器名称:ViewContext.RouteData.Values["controller"].ToString();获取Action名称:ViewContext.RouteData.Values["action"].ToString();获取路由参数值:ViewContext.RouteData.Values[名称].ToString();如:ViewContext.RouteData.Values["ID"].ToString(); 获取ID的值 阅读全文

posted @ 2013-04-02 21:55 fishyk

USING ROUTING WITH WEB FORMS
摘要:routes.MapPageRoute("product-search", "albums/search/{term}", "~/aspx/AlbumSearch.aspx"); routes.MapRoute( "Default", // Route name "{controller}/{action}/{id}", // URL with parameters new { controller = "Home", action = "Index", 阅读全文

posted @ 2013-03-12 14:16 fishyk

CUSTOM ROUTE CONSTRAINTS
摘要:routes.MapRoute(“name”, “{controller}”, null, new {httpMethod = new HttpMethodConstraint(“GET”)} ); 阅读全文

posted @ 2013-03-12 13:45 fishyk

Area Route Conflicts
摘要:防止相同名字的controller冲突,可以在配置路由的时候添加命名空间:routes.MapRoute( "Default", "{controller}/{action}/{id}", new { controller = "Home", action = "Index", i... 阅读全文

posted @ 2013-03-08 14:56 fishyk

client validation
摘要:首先要引用validation.js[Required(ErrorMessage = "An Album Title is required")][StringLength(160)]public string Title { get; set; }[Required(ErrorMessage = ... 阅读全文

posted @ 2013-03-05 15:13 fishyk

MVC AJAX
摘要:Use: @Ajax.ActionLink("Click here to see today's special!", "DailyDeal", new AjaxOptions{ UpdateTargetId = "dailydeal", InsertionMode... 阅读全文

posted @ 2013-03-04 18:03 fishyk

Self Validation
摘要:public class Others : IValidatableObject { public IEnumerable Validate(ValidationContext validationContext) { if (Name !=... 阅读全文

posted @ 2013-02-19 17:58 fishyk

ValidationAttribute
摘要:public class MaxWordsAttribute : ValidationAttribute { public MaxWordsAttribute() : base(() => { return "{0} has too many words.... 阅读全文

posted @ 2013-02-19 17:39 fishyk

validate annotations
摘要:[Required][StringLength(160)][StringLength(160, MinimumLength=3)][RegularExpression(@”[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4}”)]public string ... 阅读全文

posted @ 2013-02-18 17:07 fishyk

HTML HELPER Link
摘要:@Html.ActionLink("Link Text", "Edit", "StoreManager", new { id = 1 }, null) //名称,action,controller ,value,htmlattribute; ... 阅读全文

posted @ 2013-02-07 15:54 fishyk

RadioButton
摘要:@Html.RadioButton("color","red")@Html.RadioButton("color", "blue", true)@Html.RadioButton("color", "green")或者:@Html.RadioButtonFor(m => m.GenreId, "1"... 阅读全文

posted @ 2013-02-06 17:56 fishyk

修改model 出现错误.Model Backing the DB context has changed since the database was created。
摘要:修改model 出现以下错误:Model Backing the DB context has changed since the database was created。修改方法: 阅读全文

posted @ 2013-02-06 17:40 fishyk

Template Helper
摘要:Model:public class Album { public virtual int AlbumId { get; set; } [DisplayName("DisplayName for genreId")] public virtual in... 阅读全文

posted @ 2013-02-06 17:36 fishyk

导航