62,271
社区成员
发帖
与我相关
我的任务
分享
<script language="javascript" type="text/javascript">
var yb;
function yan()
{
var danhao=document.getElementById("b_num").value;
/*alert(danhao);*/
yb=new ActiveXObject("Msxml2.XMLHTTP.3.0");
yb.onreadystatechange=jieshou;
yb.open("GET","Handler.ashx?danhao="+danhao,true);
yb.send(null);
}
function jieshou()
{
if(yb.readyState==4)
{
alert(yb.responseText);
if(yb.responseText=="1")
{
window.confirm('单号已存在,是否继续?');
}
}
}
</script>
<asp:TextBox ID="b_num" runat="server" onblur="yan()"></asp:TextBox>
<%@ WebHandler Langua0ge="C#" Class="Handler" %>
using System;
using System.Web;
using System.Data;
public class Handler : IHttpHandler {
public void ProcessRequest (HttpContext context) {
context.Response.ContentType = "text/plain";
context.Response.Write("Hello World");
//禁止缓存
context.Response.Expires = -1;//相对过期时间
context.Response.ExpiresAbsolute = DateTime.Now.AddDays(-1);//绝对过期时间
context.Response.CacheControl = "no-cache";
context.Response.AddHeader("pragma", "no-cache");
context.Response.AddHeader("cache-control", "private");
string danhao = context.Request.QueryString.Get("danhao");
string sql = string.Format("select * from wfg_t_bill where b_num='{0}'",
danhao);
DataSet ds = DB.Query(sql);
context.Response.Clear();
if (ds.Tables[0].Rows.Count > 0)
{
context.Response.Write("1");
}
else
{
context.Response.Write("0");
}
context.Response.End();
}
public bool IsReusable {
get {
return false;
}
}
}