ASP tutorial. net Files
@ WebHandler language= "C #" class= "handler"%>
using System;
Using System.Web;
Using System.Collections.Generic;
Using System.Data;
public class Handler:ihttphandler
{
public void GetPage (HttpContext context)
{
int pagenum = Convert.ToInt32 (context.request["Pagenum"]); pagenum++;
if (Pagenum <= 3)
{
Dataset1.productdatatable CacheData = (dataset1.productdatatable) context.cache["CacheKey"];
if (CacheData = null)
{
CacheData = new Dataset1tableadapters.producttableadapter (). GETDATABYPRICEASC (1, 15);
Context.Cache.Insert ("CacheKey", CacheData, NULL, System.web.caching.cache.noabsoluteexpiration, Timespan.fromseconds (80));
}
List<product> news = new list<product> ();
for (int i = (Pagenum * 5)-4; I <= pagenum * 5; i++)
{
Dataset1.productrow row = cachedata[i-1];
string s = Link.toproduct (row.productid.tostring ());
News.add (new Product ()
{
Name = Row.name,
Description = Row.description,
Price = Row.price.tostring (),
thumbnail = Row.thumbnail,
Path = s
});
}
System.web.script.serialization. Web Effects Serializer JSS = new System.web.script.serialization.javascriptserializer ();
Context.Response.Write (News) (jss.serialize);
}
Else
{
var data = new Dataset1tableadapters.producttableadapter (). GETDATABYPRICEASC (Pagenum * 5)-4, Pagenum * 5);
List<product> news = new list<product> ();
for (int i =0 i <5; i++)
{
Dataset1.productrow row = Data[i];
string s = Link.toproduct (row.productid.tostring ());
News.add (new Product ()
{
Name = Row.name,
Description = Row.description,
Price = Row.price.tostring (),
thumbnail = Row.thumbnail,
Path = s
});
}
System.web.script.serialization.javascriptserializer JSS = new System.web.script.serialization.javascriptserializer ();
Context.Response.Write (News) (jss.serialize);
}
}
public void ProcessRequest (HttpContext context)
{
Context.response.contenttype = "Text/plain";
String action = context.request["Action"];
if (action = = "GetPage")
{
int allcount = new Dataset1tableadapters.producttableadapter (). GetCount (). value;
Context.Response.Write (Allcount);
}
else if (action = = "GETPAGEDATEASC")
{
GetPage ("GETPAGEDATEASC", context);
}
else if (action = = "Getpagedatedesc")
{
GetPage ("Getpagedatedesc", context);
}
}
public bool IsReusable
{
Get
{
return false;
}
}
}
public class product
{
public string name {set;
public string Description {set;
public string Price {set;
public string thumbnail {set;
public string Path {set;
}
HTML code
<!doctype HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "http://www.w3.org/tr/xhtml1/dtd/ Xhtml1-transitional.dtd ">
<html xmlns= "http://www.w3.org/1999/xhtml" >
<head>
<title></title>
<link href= "app_themes/balloonshopdefault/balloonshop.css Tutorial" rel= "stylesheet" type= "Text/css"/>
<link href= "Pagination.css" rel= "stylesheet" type= "Text/css"/>
<script src= "new Folder 1/jscript.js" Type= "Text/javascript" >
</script><script src= "new Folder 1/jquery.pagination.js" Type= "Text/javascript" ></script>
<script type= "Text/javascript" >
function Createlink () {
$ ("#pagination a"). each (function (i) {
if (!isnan (parseint (this.innerhtml)) {
This.href = "/balloonshop/balloons-for-children/message-balloons/page=" + parseint (this.innerhtml);
}
});
}
var data;
$ (function () {
$.post ("Handler.ashx", {"Action": "GetPage"}, Function (data123, status) {
& nbsp; data=data123;
initdata (0);
});
});
function Pageselectcallback (page_id, JQ) {
InitData (page_id);
return false;
};
function InitData (pageindx) {
$.post ("Handler.ashx", {"Action": "Getpagedate", "Pagenum": Pageindx}, function (data, status) {
if (status = = "Success") {
var datas = $.parsejson (data);
$ ("#myul"). empty ();
for (var i = 0; i < datas.length; i++) {
var p = datas[i];
var li = $ ("<li>" + "<h3 class= ' producttitle ' > <a href= '" + P.path + "' >" + p.name + "</a></h3&" gt; "+
"<a href= '" + P.path + "' >" + "<img src=" + "productimages/" + p.thumbnail + "/>" + "</a>"
+p.description+ "<p class= ' detailsection ' >+ Price:" +p.price+ "</p></li>");
$ ("#myul"). Append (LI);
}
};
});
$ ("#pagination"). Pagination (data, {
Callback:pageselectcallback,
Prev_text: ' << prev ',
Next_text: ' next page >> ',
Items_per_page:5,
Num_display_entries:4,
Current_page:pageindx,
Num_edge_entries:1
});
Createlink ();
}
</script>
</head>
<body>
<a href= "Catalog.aspx" ></a>
<ul style= "List-style-type:none" id= "Myul" ></ul>
<div id= "pagination" class= "Digg" style= "Float:left"/>
</body>
</html>
<!doctype HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "http://www.w3.org/tr/xhtml1/dtd/ Xhtml1-transitional.dtd ">
<html xmlns= "http://www.w3.org/1999/xhtml" >
<head>
<title></title>
<link href= "App_themes/balloonshopdefault/balloonshop.css" rel= "stylesheet" type= "Text/css"/>
<link href= "Pagination.css" rel= "stylesheet" type= "Text/css"/>
<script src= "new Folder 1/jscript.js" Type= "Text/javascript" >
</script><script src= "new Folder 1/jquery.pagination.js" Type= "Text/javascript" ></script>
<script type= "Text/javascript" >
function Createlink () {
$ ("#pagination a"). each (function (i) {
if (!isnan (parseint (this.innerhtml)) {
This.href = "/balloonshop/balloons-for-children/message-balloons/page=" + parseint (this.innerhtml);
}
});
}
var data;
$ (function () {
$.post ("Handler.ashx", {"Action": "GetPage"}, Function (data123, status) {
& nbsp; data=data123;
initdata (0);
});
});
function Pageselectcallback (page_id, JQ) {
InitData (page_id);
return false;
};
function InitData (pageindx) {
$.post ("Handler.ashx", {"Action": "Getpagedate", "Pagenum": Pageindx}, function (data, status) {
if (status = = "Success") {
var datas = $.parsejson (data);
$ ("#myul"). empty ();
for (var i = 0; i < datas.length; i++) {
var p = datas[i];
var li = $ ("<li>" + "<h3 class= ' producttitle ' > <a href= '" + P.path + "' >" + p.name + "</a></h3&" gt; "+
"<a href= '" + P.path + "' >" + "<img src=" + "productimages/" + p.thumbnail + "/>" + "</a>"
+p.description+ "<p class= ' detailsection ' >+ Price:" +p.price+ "</p></li>");
$ ("#myul"). Append (LI);
}
};
});
$ ("#pagination"). Pagination (data, {
Callback:pageselectcallback,
Prev_text: ' << prev ',
Next_text: ' next page >> ',
Items_per_page:5,
Num_display_entries:4,
Current_page:pageindx,
Num_edge_entries:1
});
Createlink ();
}
</script>
</head>
<body>
<a href= "Catalog.aspx" ></a>
<ul style= "List-style-type:none" id= "Myul" ></ul>
<div id= "pagination" class= "Digg" style= "Float:left"/>
</body>
</html>