llk8

MVC开发/常见错误集锦

  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

学习笔记

1.路由 (和 URL重写有点像)  {controller}/{action}/{id}

Controller

ActionName

Parameters

控制器

方法.默认为index

传入参数

 

2.上下文

     public class MovieDBContext : DbContext

     {
         public DbSet<Movie> Movies { get; set; }
     }

 

3.http://blog.csdn.net/zgjsczwj/article/details/7698184

提交表单:方法/控制器/提交方式

(Html.BeginForm("SearchIndex", "Movies", FormMethod.Get)

    

1)@Html.DisplayNameFor(model => model.Title)是显示列名,

(2)@Html.DisplayFor(modelItem => item.Title)是显示列的内容

(3)@Html.ActionLink("Create New", "Create")是超链接,跳转到model中的create页面,引用的是controller中create方法;

(4)@Html.ActionLink("Edit", "Edit", new { id=item.ID })编辑页面;

(5)@using (Html.BeginForm()) {   @Html.ValidationSummary(true)}用于客户端验证,其Html.BeginForm()表示在本页显示

(6) <div class="editor-label">
            @Html.LabelFor(model => model.Time)标签
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.Time)编辑框
            @Html.ValidationMessageFor(model => model.Time)验证合法性错误显示
        </div>

 

4.结构

QM.Common  常用操作、加密解密、获取appkey、枚举类型、过滤字符、序列化对象、获取插入session、正则判断、常量

QM.Data.Context 与数据库的交互上下文

QM.Domain 数据字典 、包含该类下边对应信息,对应的包含列表信息

 

ConsumeRecordInfo.cs

public virtual PaymentModeInfo PaymentMode{ get; set; }

 

 

PaymentModeInfo.cs

public PaymentModeInfo()

        {

            this.ConsumeRecord = new List<ConsumeRecordInfo>();

        }

public virtual ICollection<ConsumeRecordInfo> ConsumeRecord { get; set; }

 

 

 

QM.Mvc.Core 用户是否登录等

QM.Mvc.Service 增删改,获取分页查询数据等

QM.Mvc.ViewModel 视图模型、前端验证、查看,用于提交操作用显示一些验证性质

QM.Mvc.Web 网站程序

App_Start/RouteConfig.cs 路由规则

Controllers 控制器程序

Views 视图

 

在MVC中验证属性主要包含在System.ComponentModel.DataAnnotations.dll程序集中,所以需要对其添加引用。

 

 

posted on 2014-01-04 17:12  llk8  阅读(169)  评论(0编辑  收藏  举报