This article will explain another framework of Ajax Xcallback through the Repeater Ajax pagination example. Of course, no matter what Ajax frame you're a fan of, this paging is very practical, you can make the application and you like the framework, after all, everyone likes repeater flexible and fast, but did not provide built-in paging, now you just add a statement on the page can achieve Ajax effect of pagination, the article The statement also will be xcallback and JQ in Ajax use to do a comparison, if I do not speak well, welcome JQ fans correct. We first look at the front and back page, as well as online examples, if it is helpful, then look down, the sample source and everything.
Here is the front page need to write the JS code only the following statements, GetPage contains methods for returning data before and from the server [Note: Ajax.reg (' to pass data ', ' server-side method ')], if the background page has only one callable method, the server method name can be omitted, In fact, you can write more than one statement on the top of Ajax.reg (). These statements will occur before the callback, and you can also write multiple statements below the return, which will be executed after the server returns the data, so that the function structure has many advantages, allowing the data state to be consistent before and after the callback. Keep the context consistent, can be better to share variables, JQ in Ajax use is also because of simplicity and popular, I believe that this xcallback code and JQ have a ratio, or even more concise, there is no superfluous things, completely focus your attention on the business, rather than specific technical details.
<%@ Page language= "C #" autoeventwireup= "true" codefile= "Default.aspx.cs" inherits= "_default"%>
<! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">
<title></title>
<script type= "Text/javascript" >
onload = function () {
GetPage (0);
}
function GetPage (pindex) {
Ajax.reg (Pindex, "");
Return
$ ("page"). InnerHTML = ajax.x;
}
</script>
<style type= "Text/css" >
. a{height:20px; line-height:20px border-bottom:1px solid #d8dfea; clear:both;
. b{float:left; width:30px;}
. c{float:left; width:500px;}
</style>
<link href= "Page.css" rel= "stylesheet" type= "Text/css"/>
<body>
<form id= "Form1" runat= "Server" >
<div id= "Page" >
<asp:repeater id= "Rep" runat= "Server" >
<ItemTemplate>
<div class=a>
<div class=b>
<%# DataBinder.Eval (Container.DataItem, "id")%>
</div>
<div class=c><%# DataBinder.Eval (Container.DataItem, "title")%>
</div>
</div>
</ItemTemplate>
</asp:Repeater>
</div>
</form>
</body>