网站导航免费论文 原创论文 论文搜索 原创论文 网学软件 学术大家 资料中心 会员中心 问题解答 原创论文 大学论文导航 设计下载 最新论文 下载排行 原创论文 论文源代码
返回网学首页
网学联系
最新论文 推荐专题 热门论文 素材专题
当前位置: 网学 > 编程文档 > ASP.net > 正文

详解ASP.NET MVC 3新的Layout布局系统

来源:http://myeducs.cn 联系QQ:点击这里给我发消息 作者: 用户投稿 来源: 网络 发布时间: 13/01/06
MyLayout.cshtml替换如下:

  1. @{  
  2.     IList<Mvc3Application1.StudentEntity> studentEntities = Mvc3Application1.ReaderSQL_Date.GetAllStudent();  
  3. }  
  4. <!DOCTYPE html> 
  5.  
  6. <html> 
  7. <head> 
  8.     <title>@ViewBag.Title</title> 
  9. </head> 
  10. <body> 
  11.     <div> 
  12.  
  13.         @{  
  14.             <table> 
  15.                 <tr> 
  16.                     <th>学号</th> 
  17.                     <th>姓名</th> 
  18.                     <th>年龄</th> 
  19.                 </tr> 
  20.                 @foreach (Mvc3Application1.StudentEntity item in studentEntities)  
  21.                 {  
  22.                     <tr> 
  23.                         <td>@item.S_No</td> 
  24.                         <td>@item.S_Name</td> 
  25.                         <td>@item.S_Age</td> 
  26.                     </tr> 
  27.                 }  
  28.             </table> 
  29.         }  
  30.  
  31.         开始渲染Body<br /> 
  32.         @RenderBody()  
  33.         渲染Body结束<br /> 
  34.         <br /> 
  35.         开始渲染其他页<br /> 
  36.         @RenderPage("~/Views/Home/ViewPage1.cshtml")  
  37.         渲染其他页结束<br /> 
  38.         <br /> 
  39.         HOHO,开始学习Section了<br /> 
  40.         开始渲染Section<br /> 
  41.         声明方式1(推荐):SectionA:<br /> 
  42.         @RenderSection("SectionA", false)  
  43.         -------<br /> 
  44.           
  45.         声明方式2:SectionB:<br /> 
  46.         @{  
  47.             if (IsSectionDefined("SectionB"))  
  48.             {  
  49.                 @RenderSection("SectionB")  
  50.             }  
  51.         }  
  52.         -------<br /> 
  53.         渲染Sction结束<br /> 
  54.     </div> 
  55. </body> 
  56. </html> 

网学推荐

免费论文

原创论文

设为首页 | 加入收藏 | 论文首页 | 论文专题 | 设计下载 | 网学软件 | 论文模板 | 论文资源 | 程序设计 | 关于网学 | 站内搜索 | 网学留言 | 友情链接 | 资料中心
版权所有 QQ:3710167 邮箱:3710167@qq.com 网学网 [Myeducs.cn] 您电脑的分辨率是 像素
Copyright 2008-2015 myeducs.Cn www.myeducs.Cn All Rights Reserved 湘ICP备09003080号