摘要: 创建名称为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-03-11 18:06 真诚待 阅读(272) 评论(0) 推荐(0) 编辑
摘要: 编写一个视图显示列表信息实例。1、添加数据,通过ViewBag属性在视图中遍历数据。控制器中代码如下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 as 阅读全文
posted @ 2013-03-11 17:55 真诚待 阅读(557) 评论(0) 推荐(0) 编辑