最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

一則C#簡潔瀑布流代碼

 更新時間:2014年06月11日 10:49:36   作者:  
最近想實現(xiàn)數(shù)據(jù)的延遲加載,網上找一下有很多例子,看了Masonry的例子啟發(fā),自己寫了一個很簡潔的代碼。分享給大家

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加載一次數(shù)據(jù)
        var loading = $("#loading").data("on", false);//通過給loading這個div增加屬性on,來判斷執(zhí)行一次ajax請求
        $(window).scroll(function () {
            if ($("#loading").data("on"))//
            {
                return;
            }
            var isButtom = $(document).scrollTop() > ($(document).height() - $(window).height() - $("#Footer").height());
            if (isButtom) {//頁面拖到底部了
                //加載更多數(shù)據(jù)
                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);
        }

相關文章

  • C#8 的模式匹配實現(xiàn)

    C#8 的模式匹配實現(xiàn)

    這篇文章主要介紹了C#8 的模式匹配實現(xiàn),文中通過示例代碼介紹的非常詳細,對大家的學習或者工作具有一定的參考學習價值,需要的朋友們下面隨著小編來一起學習學習吧
    2019-12-12
  • c# 如何用組合替代繼承

    c# 如何用組合替代繼承

    這篇文章主要介紹了c# 如何用組合替代繼承,幫助大家更好的理解和學習使用c#,感興趣的朋友可以了解下
    2021-02-02
  • C#編譯器對局部變量的優(yōu)化指南

    C#編譯器對局部變量的優(yōu)化指南

    這篇文章主要給大家介紹了關于C#編譯器對局部變量的優(yōu)化指南,文中通過示例代碼介紹的非常詳細,對大家的學習或者工作具有一定的參考學習價值,需要的朋友們下面隨著小編來一起學習學習吧
    2020-11-11
  • C#中的==運算符

    C#中的==運算符

    這篇文章主要介紹了C#中的==運算符,非常不錯,具有參考借鑒價值,需要的朋友可以參考下
    2017-06-06
  • C#中的協(xié)變與逆變深入講解

    C#中的協(xié)變與逆變深入講解

    這篇文章主要給大家介紹了關于C#中協(xié)變與逆變的相關資料,文中通過示例代碼介紹的非常詳細,對大家的學習或者工作具有一定參考學習價值,需要的朋友們下面隨著小編來一起學習學習吧
    2018-12-12
  • C#中將字符串轉換為整型的三種解決方法總結

    C#中將字符串轉換為整型的三種解決方法總結

    本篇文章是對C#中將字符串轉換為整型的三種解決方法進行了詳細的分析介紹,需要的朋友參考下
    2013-06-06
  • 基于C#?wpf實現(xiàn)桌面放大鏡

    基于C#?wpf實現(xiàn)桌面放大鏡

    做桌面截屏功能時需要放大鏡,顯示鼠標所在位置的放大圖像,所以本文為大家介紹了如何基于C#?wpf實現(xiàn)桌面放大鏡功能,有需要的小伙伴可以參考下
    2023-09-09
  • C#表達式目錄樹示例詳解

    C#表達式目錄樹示例詳解

    這篇文章主要給大家介紹了關于C#表達式目錄樹的相關資料,文中通過示例代碼介紹的非常詳細,對大家的學習或者工作具有一定的參考學習價值,需要的朋友們下面隨著小編來一起學習學習吧
    2020-10-10
  • 積累Visual Studio 常用快捷鍵的動畫演示

    積累Visual Studio 常用快捷鍵的動畫演示

    在代碼開發(fā)過程中,頻繁的使用鍵盤、鼠標操作非常麻煩,影響程序的開發(fā)效率。如何操作能用鍵盤來操作,那就節(jié)省時間了。下面小編把我平時積累的有關visul studio 常用快捷鍵的動畫演示分享給大家,僅供大家參考
    2015-10-10
  • c#實現(xiàn)sunday算法實例

    c#實現(xiàn)sunday算法實例

    Sunday算法思想跟BM算法很相似,在匹配失敗時關注的是文本串中參加匹配的最末位字符的下一位字符,下面是用C#實現(xiàn)sunday的實例代碼,有需要的朋友可以參考一下
    2013-08-08

最新評論

南平市| 巨野县| 永平县| 巴楚县| 乐安县| 井冈山市| 饶平县| 纳雍县| 简阳市| 于田县| 日照市| 浪卡子县| 襄垣县| 凉山| 承德市| 桦甸市| 宁安市| 大名县| 山西省| 安远县| 屏南县| 黎川县| 祁连县| 甘泉县| 江城| 大冶市| 资兴市| 胶州市| 开封县| 祁连县| 靖江市| 龙游县| 贵阳市| 贡嘎县| 绥宁县| 东台市| 铜陵市| 元江| 南通市| 云梦县| 九台市|