摘要: 在利用javascript为DOM Element添加事件处理程序时,如果要想下兼容IE6,7时,就不得不考虑addEventListener与attachEvent的异同。 1.首先说下addEventListener,现在IE9+,chrome,firefox等都支持。 所有的DOM节点包含addEventListener,并且接受3个参数: HTMLElement.addEventLi... 阅读全文
posted @ 2014-01-08 12:13 ML Guo 阅读(325) 评论(0) 推荐(0) 编辑
摘要: 概述 ASP.NET MVC中,是依靠某些文件夹以及类的固定命名规则去组织model实体层,views视图层和控制层的。如果是大规模的应用程序,经常会由不同功能的模块组成,而每个功能模块都由MVC中的三层所构成,因此,随着应用程序规模的增大,如何组织这些不同功能模块中的MVC三层的目录结构,有时对开发者来说显得是种负担。所幸,MVC提供了Area机制,让开发人员可以对项目实现模块的... 阅读全文
posted @ 2013-10-25 16:03 ML Guo 阅读(975) 评论(0) 推荐(0) 编辑
摘要: 在做MVC+EF CodeFirst 的Demo时,碰到的问题,在组册用户时,要让用户输入确认密码,但是数据库中又不需要保存这个字段,解决方案很多了,这里我列出通过EF Code First的解决方案。 UserInfo实体 public class UserInfoModel { [UIHint("HiddenInput")] public int UserId { get; set; } [Display(Name = "用户名")] public string UserName { get; set; } ... 阅读全文
posted @ 2013-08-26 17:13 ML Guo 阅读(616) 评论(0) 推荐(0) 编辑
摘要: 接上篇的问题,给出我自己的解决方案。同时推荐要学习MVC的可以参考下《ASP.NET MVC4 框架揭秘》。首先,要自定义JSonResult,就要明白MVC中 JsonResult的定义。源码要自己查了,这里就不罗嗦了。有一点要知道的就是MVC中的JsonResult是通过JavascriptSerializer(System.Web.Scripts.Serialization.JavaScripteSerializer,要添加System.Web.Extensions.dll)来实现Json序列化和方序列化的。现在我们要做的就是改变JsonResult序列化Json的方式,改用Json.n 阅读全文
posted @ 2013-07-25 13:17 ML Guo 阅读(2411) 评论(0) 推荐(0) 编辑
摘要: 学习 EF Code First+MVC 时遇到了在请求JsonResult时出现 序列化类型 System.Data.Entity.DynamicProxies 的对象时检测到循环引用 的异常,原因是实体之间有关联关系,在序列化这些相关的数据对象的时候,产生无限循环引用的现象。 Example: public class CollegeInfoModel { public Guid CollegeId { get; set; } [Display(Name = "学院")] public string CollegeName { get... 阅读全文
posted @ 2013-07-25 12:57 ML Guo 阅读(1158) 评论(0) 推荐(0) 编辑
摘要: 使用EF对建立了关系的表新增记录时出现:An entity object cannot be referenced by multiple instances of IEntityChangeTracker 或一个实体对象不能由多个 IEntityChangeTracker 实例引用 在学习MVC+EF做demo时碰到的一个异常信息。在网上查了些,看得不是很明白,就自己折腾了一会儿。先上出错的代码: public class CollegeInfo { private StudentManageContext stuCtx=new StudentManageConte... 阅读全文
posted @ 2013-07-25 09:59 ML Guo 阅读(1579) 评论(0) 推荐(0) 编辑
摘要: 第8章Code First将走向哪里?So far, this book has covered all of the Code First components that reached their final release at the time of writing. There are, however, some notable features that are still in preview at this time that you should be aware of. You’ll gain the ability to migrate a database schem 阅读全文
posted @ 2013-07-23 17:12 ML Guo 阅读(386) 评论(0) 推荐(0) 编辑
摘要: Chapter6Controlling Database Location,Creation Process, and Seed Data第6章控制数据库位置,创建过程和种子数据In previous chapters you have seen how convention and configuration can be used to affect the model and the resulting database schema. In this chapter you will see how the convention and configuration concept ap 阅读全文
posted @ 2013-07-23 17:11 ML Guo 阅读(535) 评论(0) 推荐(0) 编辑
摘要: 第五章对数据库映射使用默认规则与配置 到目前为止我们已经领略了Code First的默认规则与配置对属性、类间关系的影响。在这两个领域内,Code First不仅影响模型也影响数据库。在这一章,你将让默认规则与配置的目光聚焦在类映射到数据库上而不影响概念模型。 我们从简单的映射开始,设法指定数据库的表名,构架与属性。在此你将掌握如何让多个类映射到一个通用表中,或将单个类映射到多个表中。最后,带您漫步各种继承架构的配置。将类名映射到数据库表名和构架名EF框架使用模型的类名的复数形式来生成数据库表名—Destination变成Destinations,Person变成People等。默认的类命名规 阅读全文
posted @ 2013-07-23 17:07 ML Guo 阅读(295) 评论(0) 推荐(0) 编辑
摘要: 第7章高级概念The Code First modeling functionality that you have seen so far should be enough to get you up and running with most applications. However, Code First also includes some more advanced functionality that you may require as your needs advance. Throughout this book you’ve seen Code First’s conve 阅读全文
posted @ 2013-07-23 17:06 ML Guo 阅读(362) 评论(0) 推荐(0) 编辑