Content为网站的内容页

View部分:

@using Droplets.Models;

@{

WenZhang content = ViewBag.content;
ViewBag.Title =content.Title ;
}

<nav class="breadcrumb noindex">
<ul class="inner cf noindex">
<li itemscope itemtype="http://data-vocabulary.org/Breadcrumb"><a href="/Home/Index" itemprop="url"><span itemprop="title">Droplets</span></a></li>
@*<li itemscope itemtype="http://data-vocabulary.org/Breadcrumb"><a href="" itemprop="url"><span itemprop="title">Systems & Products</span></a></li>*@
@*<li itemscope itemtype="http://data-vocabulary.org/Breadcrumb"><a href="" itemprop="url"><span itemprop="title">Vehicle Systems</span></a></li>*@
<li itemscope itemtype="http://data-vocabulary.org/Breadcrumb"><span itemprop="title">@content.Title</span></li>
</ul>
</nav>
<div id="contentsmall" class="content main-column" style="float:none; margin:auto;width:600px">
@MvcHtmlString.Create(content.Content) 
@*@if (content.PictureCaptions!=null)
{
<img src="@content.PictureCaptions" alt="@content.Title" style="width:70%;margin-left:auto">
}*@
</div>

 

Controller部分:

public class ContentController : AppController
{
//
// GET: /Content/
Droplets.Models.DropletsEntities db;
protected override void Dispose(bool disposing)
{
if (disposing)
{
db.Dispose();
}
base.Dispose(disposing);
}
public ActionResult Index(int id)
{
db = new DropletsEntities();
var q = from t in db.WenZhang
where t.Id == id
select t;
var wenzhang = q.FirstOrDefault();
ViewBag.content = wenzhang;
return View();
}

 

}

有了内容页,在首页传递参数时,才能显示内容

posted on 2016-04-26 16:05  ╰★╮ミ曙光ゞ  阅读(572)  评论(0编辑  收藏  举报