随笔分类 - MVC
摘要:HtmlHelper用法大全3:Html.LabelFor、Html.EditorFor、Html.RadioButtonFor、Html.CheckBoxFor@Html.***For:为由指定表示式表示对象中的 每个属性,返回对应html示例效果:一、设置通用的验证方法 Models层[csharp]view plaincopypublicclassMyStringIsChineseAttribute:ValidationAttribute{#region验证中文privatebool_myreturn=false;publicboolmyNullDefVal{get{return_myr
阅读全文
摘要:(1)@Html.DisplayNameFor(model => model.Title)是显示列名,(2) @Html.DisplayFor(modelItem=> item.Title)是显示列的内容(3) @Html.ActionLink("CreateNew", "Create")是超链接,跳转到model中的create页面,引用的是controller中create方法;(4) @Html.ActionLink("Edit", "Edit", new { id=item.ID })编辑页面;
阅读全文
摘要:使用过ASP.NET MVC的人都知道在MVC中页面后台中常用的页面跳转方法有几种,如:return View()、return RedirectToAction() 一般情况下我们返回的都是本页面,所以使用return View()就可以解决问题了,但是很多时候我们也会遇到返回的页面不是本页面的,那么就会用到后面两种,但是如果我们在页面返回的时候也要返回操作的结果的时候,我们就要对return RedirectToAction();方法进行扩展使用了。[csharp]view plaincopyprint?RedirectToAction(stringActionName);Redirect
阅读全文

浙公网安备 33010602011771号