客户端脚本简单实现Repeater的无刷新分页
最近有朋友在问,如果不使用ajax.net,ajaxpro等等开发包,有没有别的办法写客户端脚本让Repeater实现无刷新分页,答案当然是有的。其他那些开发包无非是帮我们完成好了回发的各种接口,可是,开发包面向的是通用的情况,然不得已需要引入的脚本库有相当的容量,但我们不需要全部,现介绍一种最轻量级的无刷新分页办法(以Repeater为例)。
首先说一下实现的依据,asp.net中有这样一个方法GetCallbackEventReference。它的作用是获取一个对客户端函数的引用;调用该函数时,将启动一个对服务器事件的客户端回调。先可以不用理解透这句话的意思,只需要记住它能获取一段脚本,让客户端调用后实现回发到服务端。废话不多说了,赶紧跟着操作如下:
建立一个WebSite,当然你要用WebProject也无妨,然后增加一个WebForm,假定名为default。
default.aspx内容是
default.aspx.cs内容是
首先说一下实现的依据,asp.net中有这样一个方法GetCallbackEventReference。它的作用是获取一个对客户端函数的引用;调用该函数时,将启动一个对服务器事件的客户端回调。先可以不用理解透这句话的意思,只需要记住它能获取一段脚本,让客户端调用后实现回发到服务端。废话不多说了,赶紧跟着操作如下:
建立一个WebSite,当然你要用WebProject也无妨,然后增加一个WebForm,假定名为default。
default.aspx内容是
1 <%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default"
2
3 %>
4
5 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
6
7 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
8 <html xmlns="http://www.w3.org/1999/xhtml">
9 <head runat="server">
10 <title>CallBack</title>
11
12 <script language="javascript" type="text/javascript">
13 function turnPage(pageIndex){
14 CallServer(pageIndex,'content');
15 }
16
17 function ReceiveCallback(arg,context){
18 var container = document.getElementById(context);
19 //alert(arg + " " + context);
20 container.innerHTML = arg;
21 }
22 </script>
23
24 </head>
25 <body>
26 <form id="form1" runat="server">
27 <div id="content">
28 <asp:Repeater ID="List" runat="server" OnItemDataBound="List_ItemDataBound">
29 <ItemTemplate>
30 <div>
31 用户名:<asp:Label ID="NickName" runat="server"></asp:Label>
32 QQ号:<asp:Label ID="QNumber" runat="server"></asp:Label>
33 </div>
34 </ItemTemplate>
35 </asp:Repeater>
36 </div>
37 <asp:Literal ID="Pager" runat="server"></asp:Literal>
38 </form>
39 </body>
40 </html>
2
3 %>
4
5 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
6
7 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
8 <html xmlns="http://www.w3.org/1999/xhtml">
9 <head runat="server">
10 <title>CallBack</title>
11
12 <script language="javascript" type="text/javascript">
13 function turnPage(pageIndex){
14 CallServer(pageIndex,'content');
15 }
16
17 function ReceiveCallback(arg,context){
18 var container = document.getElementById(context);
19 //alert(arg + " " + context);
20 container.innerHTML = arg;
21 }
22 </script>
23
24 </head>
25 <body>
26 <form id="form1" runat="server">
27 <div id="content">
28 <asp:Repeater ID="List" runat="server" OnItemDataBound="List_ItemDataBound">
29 <ItemTemplate>
30 <div>
31 用户名:<asp:Label ID="NickName" runat="server"></asp:Label>
32 QQ号:<asp:Label ID="QNumber" runat="server"></asp:Label>
33 </div>
34 </ItemTemplate>
35 </asp:Repeater>
36 </div>
37 <asp:Literal ID="Pager" runat="server"></asp:Literal>
38 </form>
39 </body>
40 </html>
default.aspx.cs内容是
1
using System;
2
using System.Data;
3
using System.Web;
4
using System.Text;
5
using System.Web.UI;
6
using System.Web.UI.HtmlControls;
7
using System.Web.UI.WebControls;
8
using System.IO;
9
using System.Globalization;
10![](/Images/OutliningIndicators/None.gif)
11
public partial class _Default : System.Web.UI.Page, System.Web.UI.ICallbackEventHandler
12
{
13
//每页显示记录数
14
static int PAGESIZE = 4;
15
DataTable dt = null;
16
private int currentPageIndex;
17
protected void Page_Load(object sender, EventArgs e)
18
{
19
if (!IsPostBack)
20
{
21
BindList(1, true);
22
//获取用于回调的
23
string callbackReference = ClientScript.GetCallbackEventReference(this, "arg",
24![](/Images/OutliningIndicators/InBlock.gif)
25
"ReceiveCallback", "context", false);
26
string callbackScript = string.Format("function CallServer(arg,context){{ {0}
27![](/Images/OutliningIndicators/InBlock.gif)
28
}}", callbackReference);
29
ClientScript.RegisterClientScriptBlock(this.GetType(), "CallServer",
30![](/Images/OutliningIndicators/InBlock.gif)
31
callbackScript, true);
32![](/Images/OutliningIndicators/InBlock.gif)
33
}
34
}
35![](/Images/OutliningIndicators/None.gif)
36
/// <summary>
37
/// 绑定列表
38
/// </summary>
39
/// <param name="pageIndex">翻页页码</param>
40
/// <param name="needRender">是否需要重画分页面码</param>
41
protected void BindList(int pageIndex, bool needRender)
42
{
43
DataTable dt = GetData();
44
//计算总页数
45
int pages = (dt.Rows.Count % PAGESIZE == 0) ? dt.Rows.Count / PAGESIZE :
46![](/Images/OutliningIndicators/InBlock.gif)
47
(dt.Rows.Count / PAGESIZE) + 1;
48
if (needRender)
49
RenderPager(pages);
50![](/Images/OutliningIndicators/InBlock.gif)
51
if (pageIndex > pages)
52
pageIndex = pages;
53
else if (pageIndex < 1)
54
pageIndex = 1;
55
int startId = (pageIndex - 1) * PAGESIZE + 1;
56
int endId = pageIndex * PAGESIZE;
57![](/Images/OutliningIndicators/InBlock.gif)
58
DataRow[] rows = dt.Select(string.Format("id>={0} and id<={1}", startId, endId));
59
List.DataSource = rows;
60
List.DataBind();
61
}
62![](/Images/OutliningIndicators/None.gif)
63
/// <summary>
64
/// 画出分页页码
65
/// </summary>
66
/// <param name="pages"></param>
67
protected void RenderPager(int pages)
68
{
69
StringBuilder sb = new StringBuilder();
70
int pageIndex = 1;
71
do
72
{
73
sb.AppendFormat("<a href='javascript:turnPage({0});'>{0}</a> ",
74![](/Images/OutliningIndicators/InBlock.gif)
75
pageIndex);
76
} while (pageIndex++ < pages);
77![](/Images/OutliningIndicators/InBlock.gif)
78
Pager.Text = sb.ToString();
79
}
80![](/Images/OutliningIndicators/None.gif)
81
/// <summary>
82
/// 初始化一个DataTable作数据源
83
/// </summary>
84
protected DataTable GetData()
85
{
86
if (null == Cache["Data"])
87
{
88
dt = new DataTable();
89
dt.Columns.Add("ID", typeof(int));
90
dt.Columns.Add("NickName", typeof(string));
91
dt.Columns.Add("QNumber", typeof(string));
92![](/Images/OutliningIndicators/InBlock.gif)
93
DataRow row = dt.NewRow();
94
row["ID"] = 1;
95
row["NickName"] = "人物1";
96
row["QNumber"] = "21243468";
97
dt.Rows.Add(row);
98![](/Images/OutliningIndicators/InBlock.gif)
99
row = dt.NewRow();
100
row["ID"] = 2;
101
row["NickName"] = "人物2";
102
row["QNumber"] = "9058307";
103
dt.Rows.Add(row);
104![](/Images/OutliningIndicators/InBlock.gif)
105
row = dt.NewRow();
106
row["ID"] = 3;
107
row["NickName"] = "人物3";
108
row["QNumber"] = "21243468";
109
dt.Rows.Add(row);
110![](/Images/OutliningIndicators/InBlock.gif)
111
row = dt.NewRow();
112
row["ID"] = 4;
113
row["NickName"] = "人物4";
114
row["QNumber"] = "22526451";
115
dt.Rows.Add(row);
116![](/Images/OutliningIndicators/InBlock.gif)
117
row = dt.NewRow();
118
row["ID"] = 5;
119
row["NickName"] = "人物5";
120
row["QNumber"] = "254852182";
121
dt.Rows.Add(row);
122![](/Images/OutliningIndicators/InBlock.gif)
123
row = dt.NewRow();
124
row["ID"] = 6;
125
row["NickName"] = "人物6";
126
row["QNumber"] = "81461006";
127
dt.Rows.Add(row);
128![](/Images/OutliningIndicators/InBlock.gif)
129
row = dt.NewRow();
130
row["ID"] = 7;
131
row["NickName"] = "人物7";
132
row["QNumber"] = "375772376";
133
dt.Rows.Add(row);
134![](/Images/OutliningIndicators/InBlock.gif)
135
row = dt.NewRow();
136
row["ID"] = 8;
137
row["NickName"] = "人物8";
138
row["QNumber"] = "153534649";
139
dt.Rows.Add(row);
140![](/Images/OutliningIndicators/InBlock.gif)
141
row = dt.NewRow();
142
row["ID"] = 9;
143
row["NickName"] = "人物9";
144
row["QNumber"] = "619468";
145
dt.Rows.Add(row);
146![](/Images/OutliningIndicators/InBlock.gif)
147
row = dt.NewRow();
148
row["ID"] = 10;
149
row["NickName"] = "人物10";
150
row["QNumber"] = "83223563";
151
dt.Rows.Add(row);
152![](/Images/OutliningIndicators/InBlock.gif)
153
Cache["Data"] = dt;
154
}
155
else
156
{
157
dt = Cache["Data"] as DataTable;
158
}
159
return dt;
160
}
161![](/Images/OutliningIndicators/None.gif)
162
实现ICallbackEventHandler 成员RaiseCallbackEvent
176![](/Images/OutliningIndicators/None.gif)
177
protected void List_ItemDataBound(object sender, RepeaterItemEventArgs e)
178
{
179
if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType ==
180![](/Images/OutliningIndicators/InBlock.gif)
181
ListItemType.AlternatingItem)
182
{
183
Label NickName = e.Item.FindControl("NickName") as Label;
184
Label QNumber = e.Item.FindControl("QNumber") as Label;
185![](/Images/OutliningIndicators/InBlock.gif)
186
DataRow row = e.Item.DataItem as DataRow;
187
NickName.Text = row["NickName"].ToString();
188
QNumber.Text = row["QNumber"].ToString();
189
}
190
}
191![](/Images/OutliningIndicators/None.gif)
192
/// <summary>
193
/// 获取指定控件重画的内容
194
/// </summary>
195
/// <param name="control"></param>
196
/// <returns></returns>
197
private string RenderControl(Control control)
198
{
199
StringWriter writer1 = new StringWriter(CultureInfo.InvariantCulture);
200
HtmlTextWriter writer2 = new HtmlTextWriter(writer1);
201![](/Images/OutliningIndicators/InBlock.gif)
202
control.RenderControl(writer2);
203
writer2.Flush();
204
writer2.Close();
205![](/Images/OutliningIndicators/InBlock.gif)
206
return writer1.ToString();
207
}
208
}
![](/Images/OutliningIndicators/None.gif)
2
![](/Images/OutliningIndicators/None.gif)
3
![](/Images/OutliningIndicators/None.gif)
4
![](/Images/OutliningIndicators/None.gif)
5
![](/Images/OutliningIndicators/None.gif)
6
![](/Images/OutliningIndicators/None.gif)
7
![](/Images/OutliningIndicators/None.gif)
8
![](/Images/OutliningIndicators/None.gif)
9
![](/Images/OutliningIndicators/None.gif)
10
![](/Images/OutliningIndicators/None.gif)
11
![](/Images/OutliningIndicators/None.gif)
12
![](/Images/OutliningIndicators/ExpandedBlockStart.gif)
13
![](/Images/OutliningIndicators/InBlock.gif)
14
![](/Images/OutliningIndicators/InBlock.gif)
15
![](/Images/OutliningIndicators/InBlock.gif)
16
![](/Images/OutliningIndicators/InBlock.gif)
17
![](/Images/OutliningIndicators/InBlock.gif)
18
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
19
![](/Images/OutliningIndicators/InBlock.gif)
20
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
21
![](/Images/OutliningIndicators/InBlock.gif)
22
![](/Images/OutliningIndicators/InBlock.gif)
23
![](/Images/OutliningIndicators/InBlock.gif)
24
![](/Images/OutliningIndicators/InBlock.gif)
25
![](/Images/OutliningIndicators/InBlock.gif)
26
![](/Images/OutliningIndicators/InBlock.gif)
27
![](/Images/OutliningIndicators/InBlock.gif)
28
![](/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
29
![](/Images/OutliningIndicators/InBlock.gif)
30
![](/Images/OutliningIndicators/InBlock.gif)
31
![](/Images/OutliningIndicators/InBlock.gif)
32
![](/Images/OutliningIndicators/InBlock.gif)
33
![](/Images/OutliningIndicators/ExpandedBlockEnd.gif)
34
![](/Images/OutliningIndicators/None.gif)
35
![](/Images/OutliningIndicators/None.gif)
36
![](/Images/OutliningIndicators/ExpandedBlockStart.gif)
37
![](/Images/OutliningIndicators/InBlock.gif)
38
![](/Images/OutliningIndicators/InBlock.gif)
39
![](/Images/OutliningIndicators/InBlock.gif)
40
![](/Images/OutliningIndicators/ExpandedBlockEnd.gif)
41
![](/Images/OutliningIndicators/None.gif)
42
![](/Images/OutliningIndicators/ExpandedBlockStart.gif)
43
![](/Images/OutliningIndicators/InBlock.gif)
44
![](/Images/OutliningIndicators/InBlock.gif)
45
![](/Images/OutliningIndicators/InBlock.gif)
46
![](/Images/OutliningIndicators/InBlock.gif)
47
![](/Images/OutliningIndicators/InBlock.gif)
48
![](/Images/OutliningIndicators/InBlock.gif)
49
![](/Images/OutliningIndicators/InBlock.gif)
50
![](/Images/OutliningIndicators/InBlock.gif)
51
![](/Images/OutliningIndicators/InBlock.gif)
52
![](/Images/OutliningIndicators/InBlock.gif)
53
![](/Images/OutliningIndicators/InBlock.gif)
54
![](/Images/OutliningIndicators/InBlock.gif)
55
![](/Images/OutliningIndicators/InBlock.gif)
56
![](/Images/OutliningIndicators/InBlock.gif)
57
![](/Images/OutliningIndicators/InBlock.gif)
58
![](/Images/OutliningIndicators/InBlock.gif)
59
![](/Images/OutliningIndicators/InBlock.gif)
60
![](/Images/OutliningIndicators/InBlock.gif)
61
![](/Images/OutliningIndicators/ExpandedBlockEnd.gif)
62
![](/Images/OutliningIndicators/None.gif)
63
![](/Images/OutliningIndicators/ExpandedBlockStart.gif)
64
![](/Images/OutliningIndicators/InBlock.gif)
65
![](/Images/OutliningIndicators/InBlock.gif)
66
![](/Images/OutliningIndicators/ExpandedBlockEnd.gif)
67
![](/Images/OutliningIndicators/None.gif)
68
![](/Images/OutliningIndicators/ExpandedBlockStart.gif)
69
![](/Images/OutliningIndicators/InBlock.gif)
70
![](/Images/OutliningIndicators/InBlock.gif)
71
![](/Images/OutliningIndicators/InBlock.gif)
72
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
73
![](/Images/OutliningIndicators/InBlock.gif)
74
![](/Images/OutliningIndicators/InBlock.gif)
75
![](/Images/OutliningIndicators/InBlock.gif)
76
![](/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
77
![](/Images/OutliningIndicators/InBlock.gif)
78
![](/Images/OutliningIndicators/InBlock.gif)
79
![](/Images/OutliningIndicators/ExpandedBlockEnd.gif)
80
![](/Images/OutliningIndicators/None.gif)
81
![](/Images/OutliningIndicators/ExpandedBlockStart.gif)
82
![](/Images/OutliningIndicators/InBlock.gif)
83
![](/Images/OutliningIndicators/ExpandedBlockEnd.gif)
84
![](/Images/OutliningIndicators/None.gif)
85
![](/Images/OutliningIndicators/ExpandedBlockStart.gif)
86
![](/Images/OutliningIndicators/InBlock.gif)
87
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
88
![](/Images/OutliningIndicators/InBlock.gif)
89
![](/Images/OutliningIndicators/InBlock.gif)
90
![](/Images/OutliningIndicators/InBlock.gif)
91
![](/Images/OutliningIndicators/InBlock.gif)
92
![](/Images/OutliningIndicators/InBlock.gif)
93
![](/Images/OutliningIndicators/InBlock.gif)
94
![](/Images/OutliningIndicators/InBlock.gif)
95
![](/Images/OutliningIndicators/InBlock.gif)
96
![](/Images/OutliningIndicators/InBlock.gif)
97
![](/Images/OutliningIndicators/InBlock.gif)
98
![](/Images/OutliningIndicators/InBlock.gif)
99
![](/Images/OutliningIndicators/InBlock.gif)
100
![](/Images/OutliningIndicators/InBlock.gif)
101
![](/Images/OutliningIndicators/InBlock.gif)
102
![](/Images/OutliningIndicators/InBlock.gif)
103
![](/Images/OutliningIndicators/InBlock.gif)
104
![](/Images/OutliningIndicators/InBlock.gif)
105
![](/Images/OutliningIndicators/InBlock.gif)
106
![](/Images/OutliningIndicators/InBlock.gif)
107
![](/Images/OutliningIndicators/InBlock.gif)
108
![](/Images/OutliningIndicators/InBlock.gif)
109
![](/Images/OutliningIndicators/InBlock.gif)
110
![](/Images/OutliningIndicators/InBlock.gif)
111
![](/Images/OutliningIndicators/InBlock.gif)
112
![](/Images/OutliningIndicators/InBlock.gif)
113
![](/Images/OutliningIndicators/InBlock.gif)
114
![](/Images/OutliningIndicators/InBlock.gif)
115
![](/Images/OutliningIndicators/InBlock.gif)
116
![](/Images/OutliningIndicators/InBlock.gif)
117
![](/Images/OutliningIndicators/InBlock.gif)
118
![](/Images/OutliningIndicators/InBlock.gif)
119
![](/Images/OutliningIndicators/InBlock.gif)
120
![](/Images/OutliningIndicators/InBlock.gif)
121
![](/Images/OutliningIndicators/InBlock.gif)
122
![](/Images/OutliningIndicators/InBlock.gif)
123
![](/Images/OutliningIndicators/InBlock.gif)
124
![](/Images/OutliningIndicators/InBlock.gif)
125
![](/Images/OutliningIndicators/InBlock.gif)
126
![](/Images/OutliningIndicators/InBlock.gif)
127
![](/Images/OutliningIndicators/InBlock.gif)
128
![](/Images/OutliningIndicators/InBlock.gif)
129
![](/Images/OutliningIndicators/InBlock.gif)
130
![](/Images/OutliningIndicators/InBlock.gif)
131
![](/Images/OutliningIndicators/InBlock.gif)
132
![](/Images/OutliningIndicators/InBlock.gif)
133
![](/Images/OutliningIndicators/InBlock.gif)
134
![](/Images/OutliningIndicators/InBlock.gif)
135
![](/Images/OutliningIndicators/InBlock.gif)
136
![](/Images/OutliningIndicators/InBlock.gif)
137
![](/Images/OutliningIndicators/InBlock.gif)
138
![](/Images/OutliningIndicators/InBlock.gif)
139
![](/Images/OutliningIndicators/InBlock.gif)
140
![](/Images/OutliningIndicators/InBlock.gif)
141
![](/Images/OutliningIndicators/InBlock.gif)
142
![](/Images/OutliningIndicators/InBlock.gif)
143
![](/Images/OutliningIndicators/InBlock.gif)
144
![](/Images/OutliningIndicators/InBlock.gif)
145
![](/Images/OutliningIndicators/InBlock.gif)
146
![](/Images/OutliningIndicators/InBlock.gif)
147
![](/Images/OutliningIndicators/InBlock.gif)
148
![](/Images/OutliningIndicators/InBlock.gif)
149
![](/Images/OutliningIndicators/InBlock.gif)
150
![](/Images/OutliningIndicators/InBlock.gif)
151
![](/Images/OutliningIndicators/InBlock.gif)
152
![](/Images/OutliningIndicators/InBlock.gif)
153
![](/Images/OutliningIndicators/InBlock.gif)
154
![](/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
155
![](/Images/OutliningIndicators/InBlock.gif)
156
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
157
![](/Images/OutliningIndicators/InBlock.gif)
158
![](/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
159
![](/Images/OutliningIndicators/InBlock.gif)
160
![](/Images/OutliningIndicators/ExpandedBlockEnd.gif)
161
![](/Images/OutliningIndicators/None.gif)
162
![](/Images/OutliningIndicators/ContractedBlock.gif)
176
![](/Images/OutliningIndicators/None.gif)
177
![](/Images/OutliningIndicators/None.gif)
178
![](/Images/OutliningIndicators/ExpandedBlockStart.gif)
179
![](/Images/OutliningIndicators/InBlock.gif)
180
![](/Images/OutliningIndicators/InBlock.gif)
181
![](/Images/OutliningIndicators/InBlock.gif)
182
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
183
![](/Images/OutliningIndicators/InBlock.gif)
184
![](/Images/OutliningIndicators/InBlock.gif)
185
![](/Images/OutliningIndicators/InBlock.gif)
186
![](/Images/OutliningIndicators/InBlock.gif)
187
![](/Images/OutliningIndicators/InBlock.gif)
188
![](/Images/OutliningIndicators/InBlock.gif)
189
![](/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
190
![](/Images/OutliningIndicators/ExpandedBlockEnd.gif)
191
![](/Images/OutliningIndicators/None.gif)
192
![](/Images/OutliningIndicators/ExpandedBlockStart.gif)
193
![](/Images/OutliningIndicators/InBlock.gif)
194
![](/Images/OutliningIndicators/InBlock.gif)
195
![](/Images/OutliningIndicators/InBlock.gif)
196
![](/Images/OutliningIndicators/ExpandedBlockEnd.gif)
197
![](/Images/OutliningIndicators/None.gif)
198
![](/Images/OutliningIndicators/ExpandedBlockStart.gif)
199
![](/Images/OutliningIndicators/InBlock.gif)
200
![](/Images/OutliningIndicators/InBlock.gif)
201
![](/Images/OutliningIndicators/InBlock.gif)
202
![](/Images/OutliningIndicators/InBlock.gif)
203
![](/Images/OutliningIndicators/InBlock.gif)
204
![](/Images/OutliningIndicators/InBlock.gif)
205
![](/Images/OutliningIndicators/InBlock.gif)
206
![](/Images/OutliningIndicators/InBlock.gif)
207
![](/Images/OutliningIndicators/ExpandedBlockEnd.gif)
208
![](/Images/OutliningIndicators/None.gif)
正如代码所示,需要实现ICallbackEventHandler接口的两个方法,RaiseCallbackEvent用于接收到客户端传回来的参数,GetCallbackResult是在服务端做出合适的反应后将指定的结果发送回客户端,这里是把repeater重画的内容返回了,然后在客户端ReceiveCallback函数里进行无刷新的最后展现,最想说明的是,一定要注意CallServer(pageIndex,'content');ReceiveCallback(arg,context);这两个函数的使用技巧,CallServer是服务端生成的,它的第二个参数直接决定了在什么地方无刷新,ReceiveCallback和前者都是context参数,内容就是相同的,相当于传到服务器再原封不动的传回来,因此用于回发和接收时共享数据。
小示例可变换多种实现,希望大家都能找到适合自己简便实现的办法。