|
<script type="text/Javascript">
function checkuser()
{
var option={
parameters:"userid="+$("userid").value,
method:"post",
onSuccess:function(transport){
var rp=transport.responseText;
if(rp=="true")
{
alert("該用戶昵稱存在!!");
}
else
{
alert("該用戶昵稱不存在,請重新輸入!!");
}
},
onFailure:function(transport){
alert("數據提交失敗,請檢查網絡或重試。");
}
}
var request=new Ajax.Request("Ajax.ASPx?userid="+escape($("userid").value),option);
}
</script>
昵稱:<ASP:TextBox ID="userid" runat="server" Text="" onblur="checkuser()"></ASP:TextBox>
Ajax.ASPx頁面代碼:
private void Page_Load(object sender, System.EventArgs e)
{
string userid = Request.QueryString["userid"];
string sql = "select userid from blog_user where userid='" + userid + "')";
object o = dbconn.ExecuteScalar(sql);
if (o == null)
Response.Write("false");
else
Response.Write("true");
}
AspNet技術:asp.net AJAX實現無刷新獲得數據,轉載需保留來源!
鄭重聲明:本文版權歸原作者所有,轉載文章僅為傳播更多信息之目的,如作者信息標記有誤,請第一時間聯系我們修改或刪除,多謝。