码迷,mamicode.com
首页 > Windows程序 > 详细

C#-Mvc-表白墙(随机数)

时间:2016-05-14 10:18:07      阅读:872      评论:0      收藏:0      [点我收藏+]

标签:

BiaoBai  View部分:

@using ChengJiDaoRuChaXun.Dao;
@{
    Layout = null;
    List<BiaoBai> biaobai = ViewBag.biaobai;
}

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>    
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>表白墙</title>        
    <link href="~/Content/biaobai/index.css" rel="stylesheet" />
    <script src="~/Content/biaobai/jquery-1.7.2.min.js"></script>   
    <script src="~/Content/biaobai/index.js"></script>    
    <script type="text/javascript">
        $(function () {
            $(#shuaxin).click(function () {
                window.location = window.location;
            })
        });
    </script>
    <style type="text/css">
        #shuaxin {
            display: block;
            width: 120px;
            height: 65px;
            cursor: pointer;
        background-image:url(/Content/images/chongpai.png);
        }
        #fabu {
            display: block;
            width: 120px;
            height: 65px;
            cursor: pointer;
            background-image: url(/Content/images/send.png);
        }
    </style>
    
</head>
<body>

    <div id=top>
        
       <span id=fabu style="float:left" onclick="window.location.href = ‘/Function/FaBu‘"> </span>
        <span id="shuaxin" style="float:left"></span>
    </div>

    <div id=main>
        @if (biaobai != null)
        {
            Random r = new Random();
            string c = "a";
            foreach (BiaoBai item in biaobai)
            {
                c = "a" + (r.Next(5)+1);//循环随机数的产生,a1——a5

        <dl class=paper @c>@*a1——a5*@
            <dt>
                <span class=username>@item.Name</span>               
            </dt>
            <dd class=content>@item.NeiRong</dd>
            <dd class=bottom>
                <span class=time>@item.ShiJian</span>
                <a href="" class=close></a>
            </dd>
        </dl>                
        }
        }
    </div>   
    <!--[if IE 6]>    
       <script src="~/Content/biaobai/iepng.js"></script>
    <script type="text/javascript">
    DD_belatedPNG.fix(#send,#close,.close);
    </script>
    <![endif]-->

</body>
</html>

BiaoBai  Controller部分:

  JiKaoChengJiEntities1 db;
        public FunctionController()
        {
            db = new Dao.JiKaoChengJiEntities1();
        }
        protected override void Dispose(bool disposing)
        {
            if (disposing)
            {
                db.Dispose();
            }
            base.Dispose(disposing);
        }
        // GET: Function
        public ActionResult Index()
        {
            return View();
        }
        public ActionResult BiaoBai()
        {
            var q = from t in db.BiaoBai
                    select t;
            var list = q.ToList();
            ViewBag.biaobai = list;
            return View();
        }

 

C#-Mvc-表白墙(随机数)

标签:

原文地址:http://www.cnblogs.com/DotaSteam/p/5491923.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!