最新下载
热门教程
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
asp.net ajax 简单应用实例
时间:2022-06-25 04:23:16 编辑:袖梨 来源:一聚教程网
asp教程.net文件
@ 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));
}
listnews = new list ();
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.网页特效serializer jss = new system.web.script.serialization.javascriptserializer();
context.response.write(jss.serialize(news));
}else
{var data = new dataset1tableadapters.producttableadapter().getdatabypriceasc((pagenum * 5) - 4, pagenum * 5);
listnews = new list ();
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(jss.serialize(news));
}}
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; get; }
public string description { set; get; }
public string price { set; get; }
public string thumbnail { set; get; }
public string path { set; get; }}
html代码
css" />
相关文章
- 时空中的绘旅人天宇之间怎么玩 绘旅人天宇之间活动玩法介绍 12-25
- QQ2024年度报告怎么看 2024qq年度报告玩法介绍 12-25
- 归龙潮珠砂什么时候up 归龙潮红缘绮梦卡池介绍 12-25
- 王者荣耀S38赛季有什么更新 12-25
- 王者荣耀S38赛季有什么更新 王者荣耀S38赛季更新内容介绍 12-25
- 世界之外12.25有什么更新 世界之外12月25日更新内容介绍 12-25