一个js的问题 急急 在写一个简单的验证的时候 需要判断用户名是否存在 我在另一个页面写了一个验证方法 javascript如何才能从这个页面传递参数过去让另个页面的方法获取参数进行判断 并返回结果 显示呢! 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 有没有能让我速成的ajax资料呢 只要能完成 我上面提到的功能就OK了 register.htm<!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> <script type="text/javascript"> function gethttprequest(){ var xmlhttp_request = false; try{ if( window.ActiveXObject ){ for( var i = 5; i; i-- ){ try{ if( i == 2 ){xmlhttp_request = new ActiveXObject( "Microsoft.XMLHTTP" ); }else{xmlhttp_request = new ActiveXObject( "Msxml2.XMLHTTP." + i + ".0" ); xmlhttp_request.setRequestHeader("Content-Type","text/xml");xmlhttp_request.setRequestHeader("Content-Type","gb2312"); } break;} catch(e){ xmlhttp_request = false; } } }else if( window.XMLHttpRequest ){ xmlhttp_request = new XMLHttpRequest(); if (xmlhttp_request.overrideMimeType) { xmlhttp_request.overrideMimeType('text/xml'); } } } catch(e){ xmlhttp_request = false; } return xmlhttp_request ; } function check(){ var xmlhttp=gethttprequest(); var url="check.aspx?username="+document.getElementById('Text1').value; xmlhttp.Open("get",url,false);xmlhttp.send(null);document.getElementById('div1').innerHTML=xmlhttp.responsetext;} </script></head><body> <input id="Text1" type="text" /><input id="Button1" onclick="check()" type="button" value="button" /> <div style="width: 100px; height: 100px" id="div1"> </div></body></html>check.aspx.csSqlConnection conn = new SqlConnection("uid=sa;pwd=;database=tu;server="); string name = Request["username"].Replace("'", "").Trim(); string sql = "select username from userinfo where username='" + name + "'"; SqlCommand cmd = new SqlCommand(sql, conn); conn.Open(); SqlDataReader sdr = cmd.ExecuteReader(); if (sdr.Read()) { Response.Write("该用户名已经有人使用,请重新选择!"); } else Response.Write("该用户名可以使用!"); sdr.Close(); cmd.Dispose(); conn.Close(); web开发程序问题 Dataset 中有100条记录,怎么取出第10条到第20条间的记录? 高分 无法启动调试 ASP.NET 定时器的问题 如何用C#把sql server里的一张表的内容写成一个csv文件?急,在线等。。。 如何比较两个结果集的不同 简单问题,在线等,一解决立即结贴!各位大哥大姐快帮帮忙! 关于水晶报表10集成在.net2003中的疑惑 异步 页面字体变大的问题 使用Appliction和static变量的区别是什么???? 会员前十条新闻用XML显示 VB转 C# 转完 给分
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
<title>无标题页</title>
<script type="text/javascript">
function gethttprequest(){
var xmlhttp_request = false;
try{
if( window.ActiveXObject ){
for( var i = 5; i; i-- ){
try{
if( i == 2 ){xmlhttp_request = new ActiveXObject( "Microsoft.XMLHTTP" );
}else{xmlhttp_request = new ActiveXObject( "Msxml2.XMLHTTP." + i + ".0" );
xmlhttp_request.setRequestHeader("Content-Type","text/xml");xmlhttp_request.setRequestHeader("Content-Type","gb2312");
}
break;}
catch(e){
xmlhttp_request = false;
}
}
}else if( window.XMLHttpRequest ){
xmlhttp_request = new XMLHttpRequest();
if (xmlhttp_request.overrideMimeType) {
xmlhttp_request.overrideMimeType('text/xml');
}
}
}
catch(e){
xmlhttp_request = false;
}
return xmlhttp_request ;
}
function check(){
var xmlhttp=gethttprequest();
var url="check.aspx?username="+document.getElementById('Text1').value;
xmlhttp.Open("get",url,false);
xmlhttp.send(null);
document.getElementById('div1').innerHTML=xmlhttp.responsetext;
}
</script>
</head>
<body>
<input id="Text1" type="text" /><input id="Button1" onclick="check()" type="button" value="button" />
<div style="width: 100px; height: 100px" id="div1">
</div>
</body>
</html>
check.aspx.csSqlConnection conn = new SqlConnection("uid=sa;pwd=;database=tu;server=");
string name = Request["username"].Replace("'", "").Trim();
string sql = "select username from userinfo where username='" + name + "'";
SqlCommand cmd = new SqlCommand(sql, conn);
conn.Open();
SqlDataReader sdr = cmd.ExecuteReader();
if (sdr.Read())
{
Response.Write("该用户名已经有人使用,请重新选择!");
}
else
Response.Write("该用户名可以使用!");
sdr.Close();
cmd.Dispose();
conn.Close();