手机
当前位置:查字典教程网 >编程开发 >C#教程 >一则C#简洁瀑布流代码
一则C#简洁瀑布流代码
摘要:View页面。复制代码代码如下:@{ViewBag.Title="瀑布流";Layout="~/Views/Shared/_Layout.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">

<h1>Head</h1>

</div>

<div>

<>

<div id="LefMenue">

<ul>

<li>1</li>

<li>2</li>

<li>3</li>

</ul>

</div>

<right-->

<div id="RightContent">

<div id="ProductList">

<div>

<dl>

<dt>

<img src="~/Content/Shose.jpg" /></dt>

<dd>What's up with you</dd>

</dl>

</div>

<div>

<dl>

<dt>

<img src="~/Content/Shose.jpg" /></dt>

<dd>What's up with you</dd>

</dl>

</div>

<div>

<dl>

<dt>

<img src="~/Content/Shose.jpg" /></dt>

<dd>What's up with you</dd>

</dl>

</div>

<div>

<dl>

<dt>

<img src="~/Content/Shose.jpg" /></dt>

<dd>What's up with you</dd>

</dl>

</div>

<div>

<dl>

<dt>

<img src="~/Content/Shose.jpg" /></dt>

<dd>What's up with you</dd>

</dl>

</div>

<div>

<dl>

<dt>

<img src="~/Content/Shose.jpg" /></dt>

<dd>What's up with you</dd>

</dl>

</div>

<div>

<dl>

<dt>

<img src="~/Content/Shose.jpg" /></dt>

<dd>What's up with you</dd>

</dl>

</div>

<div>

<dl>

<dt>

<img src="~/Content/Shose.jpg" /></dt>

<dd>What's up with you</dd>

</dl>

</div>

<div>

<dl>

<dt>

<img src="~/Content/Shose.jpg" /></dt>

<dd>What's up with you</dd>

</dl>

</div>

<div>

<dl>

<dt>

<img src="~/Content/Shose.jpg" /></dt>

<dd>What's up with you</dd>

</dl>

</div>

<div>

<dl>

<dt>

<img src="~/Content/Shose.jpg" /></dt>

<dd>What's up with you</dd>

</dl>

</div>

<div>

<dl>

<dt>

<img src="~/Content/Shose.jpg" /></dt>

<dd>What's up with you</dd>

</dl>

</div>

</div>

</div>

<div></div>

</div>

<div id="loading">

<span>加载中,请稍后...</span>

</div>

<div></div>

<div id="Footer"></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+data[i]+"px">";

html += "<div>";

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#简洁瀑布流代码】相关文章:

c# 共享状态的文件读写实现代码

C#线程池用法详细介绍

用C#操纵IIS(代码)

C#版ftp方法实现类的代码

C#实现协同过滤算法的实例代码

C#获取计算机名,IP,MAC信息实现代码

C#编写的windows计算器的实例代码

利用thrift实现js与C#通讯的实例代码

C# 游戏外挂实现核心代码

C#软件注册码的实现代码

精品推荐
分类导航