您现在的位置是:网站首页> 编程资料编程资料

Ajax动态加载数据库示例_AJAX相关_

2023-05-25 264人已围观

简介 Ajax动态加载数据库示例_AJAX相关_

复制代码 代码如下:











产品名称:



价格:







复制代码 代码如下:

<%@ WebHandler Language="C#" Class="GetPrice" %>

using System;
using System.Linq;
using System.Web;
using DataSetProductsTableAdapters;

public class GetPrice : IHttpHandler {

public void ProcessRequest (HttpContext context)
{
context.Response.ContentType = "text/plain";
//context.Response.Write("Hello World");
string name = context.Request["text1"];
var data = new PriceTableAdapter().GetDataByName(name);//需要建一个强类型的dataset
if (data.Count <= 0)
{
context.Response.Write("none|0");
}
else
{
context.Response.Write("ok|" + data.Single().Price);
}
}

public bool IsReusable {
get {
return false;
}
}

}

-六神源码网