register.aspx页面代码:
<scripttype="text/javascript">
functioncheckuser()
{
varoption={
parameters:"userid="+$("userid").value,
method:"post",
onSuccess:function(transport){
varrp=transport.responseText;
if(rp=="true")
{
alert("该用户昵称存在!!");
}
else
{
alert("该用户昵称不存在,请重新输入!!");
}
},
onFailure:function(transport){
alert("数据提交失败,请检查网络或重试。");
}
}
varrequest=newAjax.Request("Ajax.aspx?userid="+escape($("userid").value),option);
}
</script>
昵称:<asp:TextBoxID="userid"runat="server"Text=""onblur="checkuser()"></asp:TextBox>
Ajax.aspx页面代码:
privatevoidPage_Load(objectsender,System.EventArgse)
{
stringuserid=Request.QueryString["userid"];
stringsql="selectuseridfromblog_userwhereuserid='"+userid+"')";
objecto=dbconn.ExecuteScalar(sql);
if(o==null)
Response.Write("false");
else
Response.Write("true");
}