zoukankan      html  css  js  c++  java
  • C#网站开发之内容页Content

    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;600px">
    @MvcHtmlString.Create(content.Content) 
    @*@if (content.PictureCaptions!=null)
    {
    <img src="@content.PictureCaptions" alt="@content.Title" style="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();
    }

    }

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

  • 相关阅读:
    FTPClient使用中的问题--获取当前工作目录为null
    MGR安装
    脚本在Shell可以执行成功,放到crontab里执行失败
    使用Python通过SMTP发送邮件
    MySQL Router
    事务管理(ACID)
    mysqldump使用
    MySQL InnoDB Cluster
    Linux LVM逻辑卷配置过程详解(创建、扩展、缩减、删除、卸载、快照创建)
    centos命令行控制电脑发出滴滴声
  • 原文地址:https://www.cnblogs.com/DotaSteam/p/5435478.html
Copyright © 2011-2022 走看看