程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> .NET網頁編程 >> C# >> C#入門知識 >> 一則C#簡練瀑布流代碼

一則C#簡練瀑布流代碼

編輯:C#入門知識

一則C#簡練瀑布流代碼。本站提示廣大學習愛好者:(一則C#簡練瀑布流代碼)文章只能為提供參考,不一定能成為您想要的結果。以下是一則C#簡練瀑布流代碼正文


View頁面。


@{
        ViewBag.Title = "瀑布流";
        Layout = "~/Views/Shared/_Layout.cshtml";
    }
@section header{
    <script src="~/Scripts/jquery-ui-1.8.24.min.js"></script>
         <style type="text/css">
        .* {
         margin:0px;
         padding:0px;
        }
        body {
            margin-left:auto;
            margin-right:auto;
        }
        .ClearBoth {
            clear:both;
        }
        #bodyContent {
            width:1400px;
            margin-left:auto;
            margin-right:auto;
        }
        #head {
            width:100%;
            height:50px;
            margin-bottom:10px;
        }
        #LefMenue {
            width:20%;
            height:500px;
            float:left;
        }
        #RightContent {
            width:75%;
            float:right;
            border: thin solid #333;
        }
        #Footer {
            margin-top:10px;
            width:100%;
            height:40px;
        }
        .GreyBlock {
            border: thin solid #333;
            background-color:#CCC;
            width:100%;
        }
        .Item {
            float: left;
            width: 230px;
            margin:5px;
            border: 1px solid #CCC;
        }
        </style>
}
 <div id="bodyContent">
   <div id="head" class="GreyBlock">
     <h1>Head</h1>
   </div>
   <div>
           <!--Left-->
       <div id="LefMenue" class="GreyBlock">
         <ul>
           <li>1</li>
           <li>2</li>
           <li>3</li>
         </ul>
       </div>
       <!----right-->
       <div id="RightContent">
             <div id="ProductList">
               <div class="Item">
                   <dl>
                       <dt>
                           <img src="~/Content/Shose.jpg" /></dt>
                       <dd>What's up with you</dd>
                    </dl>
               </div>
               <div class="Item">
                   <dl>
                       <dt>
                           <img src="~/Content/Shose.jpg" /></dt>
                       <dd>What's up with you</dd>
                    </dl>
               </div>
               <div class="Item">
                   <dl>
                       <dt>
                           <img src="~/Content/Shose.jpg" /></dt>
                       <dd>What's up with you</dd>
                    </dl>
               </div>
               <div class="Item">
                   <dl>
                       <dt>
                           <img src="~/Content/Shose.jpg" /></dt>
                       <dd>What's up with you</dd>
                    </dl>
               </div>
               <div class="Item">
                   <dl>
                       <dt>
                           <img src="~/Content/Shose.jpg" /></dt>
                       <dd>What's up with you</dd>
                    </dl>
               </div>
               <div class="Item">
                   <dl>
                       <dt>
                           <img src="~/Content/Shose.jpg" /></dt>
                       <dd>What's up with you</dd>
                    </dl>
               </div>
               <div class="Item">
                   <dl>
                       <dt>
                           <img src="~/Content/Shose.jpg" /></dt>
                       <dd>What's up with you</dd>
                    </dl>
               </div>
               <div class="Item">
                   <dl>
                       <dt>
                           <img src="~/Content/Shose.jpg" /></dt>
                       <dd>What's up with you</dd>
                    </dl>
               </div>
               <div class="Item">
                   <dl>
                       <dt>
                           <img src="~/Content/Shose.jpg" /></dt>
                       <dd>What's up with you</dd>
                    </dl>
               </div>
               <div class="Item">
                   <dl>
                       <dt>
                           <img src="~/Content/Shose.jpg" /></dt>
                       <dd>What's up with you</dd>
                    </dl>
               </div>
               <div class="Item">
                   <dl>
                       <dt>
                           <img src="~/Content/Shose.jpg" /></dt>
                       <dd>What's up with you</dd>
                    </dl>
               </div>
               <div class="Item">
                   <dl>
                       <dt>
                           <img src="~/Content/Shose.jpg" /></dt>
                       <dd>What's up with you</dd>
                    </dl>
               </div>
             </div>
       </div>
     <div class="ClearBoth"></div>
   </div>
<div id="loading" class="loading-wrap">
    <span class="loading">加載中,請稍後...</span>
</div>
   <div class="ClearBoth"></div>
   <div id="Footer" class="GreyBlock"></div>
 </div>

@section scripts{
    <script type="text/javascript">
        var myContainer = $("#ProductList");
        //用戶拖動轉動條,到達底部時ajax加載一次數據
        var loading = $("#loading").data("on", false);//經由過程給loading這個div增長屬性on,來斷定履行一次ajax要求
        $(window).scroll(function () {
            if ($("#loading").data("on"))//
            {
                return;
            }
            var isButtom = $(document).scrollTop() > ($(document).height() - $(window).height() - $("#Footer").height());
            if (isButtom) {//頁面拖究竟部了
                //加載更多半據
                loading.data("on",true).fadeIn();
                $.get("@Url.Action("GetData","Product")", function (data) {
                    var html = CreateHtml(data);
                    var $newElems = $(html).css({ opacity: 0 }).appendTo(myContainer);
                    $newElems.animate({ opacity: 1 },3000);
                    loading.data("on", false);
                    loading.fadeOut();
                },"json");
            }
        });
        function CreateHtml(data) {
            var html = "";
            if ($.isArray(data)) {
                for (var i in data) {
                    //html += "<div class=\"Item\" style=\"height:"+data[i]+"px\">";
                    html += "<div class=\"Item\">";
                    html += "<dl>";
                    html += "<dt>";
                    html += "<img src=\"../Content/Shose.jpg\" />";
                    html += "</dt>";
                    html += "<dd>";
                    html += "What's up with you " + data[i];
                    html += "</dd>"
                    html += "</dl>"
                    html += "</div>"
                }
            }
            return html;
        }
    </script>
    }

C#辦事端:


public JsonResult GetData()
        {
            Random ro = new Random();

            List<int> vListInt = new List<int>();
            for (int i = 0; i < 12; i++)
            {
                vListInt.Add(ro.Next(400, 500));
            }
            return Json(vListInt, JsonRequestBehavior.AllowGet);
        }

  1. 上一頁:
  2. 下一頁: