Code
<%@ Page Language="C#" %>
<script runat="server">
protected void Page_Load(object sender, EventArgs e)
{
// get the candidate user name.
string candidateUserName = Request["UserName"];
// validate
bool isValid = false;
if (candidateUserName.ToLower() != "dflying")
{
isValid = true;
}
// send out result
Response.Clear();
Response.Write(isValid ? "true" : "false");
Response.Flush();
Response.Close();
}
</script>
Code
// JScript 文件
function $(id)
{
return document.getElementById(id);
}
//创建一个xmlhttp对象
function createXmlHttp()
{
var xmlHttp;
// 检测MSXMLHTTP版本,为了兼容IE各个版本
var activeKey = new Array("MSXML2.XMLHTTP.5.0","MSXML2.XMLHTTP.4.0","MSXML2.XMLHTTP.3.0","MSXML2.XMLHTTP","Microsoft.XMLHTTP");
if(window.ActiveXObject)
{
for(var i=0;i<activeKey.length;i++)
{
try
{
xmlHttp = new ActiveXObject(activeKey[i]);
if(xmlHttp!=null)
return xmlHttp;
}
catch(error)
{
throw new Error("您的浏览器版本过低,请更新浏览器");
}
}
}
else if(window.XMLHttpRequest)
{
xmlHttp = new XMLHttpRequest();
}
return xmlHttp;
}
function CheckUserName(name,alertstr)
{
$("checkname").innerHTML = " loading.";
var url = "../test/Server.aspx?action=CheckUserName";
var xmlhttp = createXmlHttp();
xmlhttp.onreadystatechange=function()
{
if(xmlhttp.readyState==4&&xmlhttp.status==200)
{
alert(xmlhttp.responseText);
$("checkname").innerHTML = "yes";
$("checkname").innerHTML = "1"+xmlhttp.responseText;
}
}
xmlhttp.open("GET",url,true);
xmlhttp.send(null);
/*
*/
}
posted @
2009-07-14 13:44
Nina
阅读(
1232)
评论()
编辑
收藏
举报