日期:2014-05-17 浏览次数:20571 次
var xmlHttp; function createXmlHttpRequest() { if (window.XMLHttpRequest) { xmlHttp = new XMLHttpRequest(); if (xmlHttp.overrideMimeType) { xmlHttp.overrideMimeType("text/xml"); } } else if (window.ActiveXObject) { try { xmlHttp = new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { xmlHttp = new ActiveXObject("Microsoft.XMLHTTP"); } } if (!xmlHttp) { window.alert("你的浏览器不支持创建XMLhttpRequest对象"); } return xmlHttp; } function checkname(name) { createXmlHttpRequest(); var url = "Customer/createcustomerAJAX.aspx?Name=" + name; xmlHttp.open("post", url, true); xmlHttp.onreadystatechange = CheckUserNameResult; xmlHttp.send(null); } function CheckUserNameResult() { if (xmlHttp.readyState == 4)//服务器响应状态 { if (xmlHttp.status == 200)//代码执行状态 { if (xmlHttp.responseText == "true") { document.getElementById("img_companyname").src = "../images/正确 .jpg"; } else { document.getElementById("imgflag").src = "../images/不能为空.jpg"; document.getElementById("Text1").style.display = true; } } } }
checkcompanyname cu = new checkcompanyname(); if (cu.checkcompany(Request.QueryString["Name"].ToString())) { Response.Write("false"); Response.End(); } else { Response.Write("true"); Response.End(); }
public bool checkcompany(string name) { string sql = "select * from customers where companyname='"+name+"'"; SqlConnection con = new SqlConnection(SqlHelper.connectionString); con.Open(); SqlCommand com = new SqlCommand(sql,con); SqlDataReader dr = com.ExecuteReader(); if (dr.Read()) { return true; } else { return false; } }