100000 개의 메시지를 표시하는 리피터 컨트롤이 있습니다. 사용자에게 모든 메시지를 표시하기 위해 다른 페이지를 사용하고 싶지 않습니다. 대신에 원하는 사용자가 한 번에 모든 메시지를로드하지 않고 아래로 스크롤하는 동안로드하십시오.asp.net에서 컨트롤에 데이터를 할당하는 방법
예 : Facebook 타임 라인. 당신은 페이스 북에서 본 것처럼, 뭔가를
<script type="text/javascript">
$(document).ready(function e() {
$(window).scroll(function() {
if ($(window).scrollTop() == $(document).height() - $(window).height()) {
GetRecords();
}
});
function GetRecords() {
$("#loader").show();
$.ajax({
type: "POST",
url: "Demo.aspx/GetList",
data: {},
contentType: "application/json; charset=utf-8",
dataType: "json",
success: OnSuccess,
failure: function (response) {
alert("Failure");
},
error: function (response) {
alert("Error");
}
});
}
function OnSuccess(response) {
$.map(response.d, function (item) {
$('#division').append("<div style='line-height:25px;'>" + item + "</div>");
});
$("#loader").hide();
}
});
</script>
코드
public partial class Demo : System.Web.UI.Page { static List<string> list = new List<string>(); static int n=0; protected void Page_Load(object sender, EventArgs e) { n = 0; } public Demo() { for (int i = 1; i <= 1000; i++) { list.Add("List Item : " + i); } } [WebMethod] public static List<string> GetList() { var fiftyItems = list.Skip(n).Take(50); n = n + 50; return fiftyItems.ToList(); } }
뒤에하지만 난 더 complected 제어 작업 할 : 내가 뭘하려 :
감사
편집 댓글, 그림 등.
나는 내 질문을 편집했습니다. –
[this answer] (http://stackoverflow.com/a/579046/944681)에 따라 aspx 페이지 (html 코드)를로드하도록 아약스 호출을 변경합니다. –