摘要: 关于初始化数据库的问题.Wiki Link: [discussion:362487]GreatDinosaurDeveloperJul 9, 2012 at 5:53 AM本项目使用codefirst模式,配置好连接串第一次访问即可建立数据库并填充基本数据另外有自定义的初始化sql脚本,供开发时用户使用非模型类的方法填充初始化数据。johnny_hyqMar 21 at 2:10 AMweb.config配置连接:<add name="DefaultConnection" connectionString="Data Source=IT-HYQ;Databa 阅读全文
posted @ 2013-04-16 10:41 风雪七月花溅墨 阅读(563) 评论(0) 推荐(0) 编辑
摘要: 通过系统自带的Authorize限制匿名访问通过在web.config,设置为form验证, 并拒绝所有的匿名用户<authentication mode="Forms"> <forms loginUrl="~/Account/Login" timeout="2880" /> </authentication>如果我们开放首页比如说Home/Index,那么做如下配置. 如果是Home文件夹下所有的页面都能访问, 那么 path=”Home”即可<location path="Hom 阅读全文
posted @ 2013-04-16 10:35 风雪七月花溅墨 阅读(272) 评论(0) 推荐(0) 编辑
摘要: 安装更新MvcScaffoldingUpdate-Package MvcScaffoldingInstall-Package MvcScaffolding定义一个Team与Player一对多的关系创建一个小组实体类public class Team{ public int TeamId { get; set; } [Required] public string Name { get; set; } public string City { get; set; } public DateTime Founded { get; set; }}加入一个球员与小组的关系pub... 阅读全文
posted @ 2013-04-16 10:32 风雪七月花溅墨 阅读(215) 评论(0) 推荐(0) 编辑
摘要: view中嵌入如下代码引入jquery-ui<script src="~/Scripts/jquery-1.6.2.min.js"></script><script src="~/Scripts/jquery.unobtrusive-ajax.min.js"></script><script src~/Scripts/jquery-ui.min.js"></script>使用jquery-ui实现特效$(function () {$("#album-list im 阅读全文
posted @ 2013-04-16 10:18 风雪七月花溅墨 阅读(769) 评论(0) 推荐(0) 编辑
摘要: AJAX Function$(function () {$("#album-list img").mouseover(function () {$(this).animate({ height: '+=25', width: '+=25' }).animate({ height: '-=25', width: '-=25' });});});jQuery Selectors选择器$(˝#header˝)id为“header”元素$(˝.editor-label˝)class为“editor-lable”元素$( 阅读全文
posted @ 2013-04-16 10:08 风雪七月花溅墨 阅读(1000) 评论(0) 推荐(0) 编辑
摘要: form搜索View中<form action="/Home/Search" method="get"><input type="text" name="q" /><input type="submit" value="Search" /></form>控制器public ActionResult Search(string q){var albums = storeDB.Albums.Include("Artist& 阅读全文
posted @ 2013-04-16 10:02 风雪七月花溅墨 阅读(540) 评论(0) 推荐(0) 编辑
摘要: 创建名称为SiteLayout.cshtml的视图@{Layout = "~/Views/Shared/SiteLayout.cshtml";www.it-ebooks.info68 x CHAPTER 3 VIEWSView.Title = "The Index!";}<p>This is the main content!</p>@section Footer {This is the <strong>footer</strong>.}Index.cshtml引入视图@{Layout = "~ 阅读全文
posted @ 2013-04-16 09:49 风雪七月花溅墨 阅读(778) 评论(0) 推荐(0) 编辑
摘要: 编写一个视图显示列表信息实例。1、添加数据,通过ViewBag属性在视图中遍历数据。控制器中代码如下方法1:public ActionResult List() {var albums = new List<Album>();for(int i = 0; i < 10; i++) {albums.Add(new Album {Title = "Product " + i});}ViewBag.Albums = albums;return View();}视图部分代码<ul>@foreach (Album a in (ViewBag.Albums 阅读全文
posted @ 2013-04-16 09:44 风雪七月花溅墨 阅读(279) 评论(0) 推荐(0) 编辑
摘要: Using Validation Annotationsusing System.ComponentModel.DataAnnotations;//命名空间Required必须项验证属性[Required]public string FirstName { get; set; }[Required]public string LastName { get; set; }StringLength长度[Required][StringLength(160)]public string LastName { get; set; }[Required][StringLength(160, Minimu 阅读全文
posted @ 2013-04-16 09:21 风雪七月花溅墨 阅读(299) 评论(0) 推荐(0) 编辑