一个AJAX用户名验证问题!请大家帮忙指点下!
后台 CS文件
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
public partial class RegisterPage : PageBase
{
UserEntity user = new UserEntity();
protected void Page_Load(object sender, EventArgs e)
{
AjaxPro.Utility.RegisterTypeForAjax(typeof(RegisterPage));
}
[AjaxPro.AjaxMethod]
public string select(string username)
{
string a = "已存在!";
string b = "可以使用";
// string username= Request.QueryString["username"].ToString();
string sql = "select * from BBS where bbsname='" + username + "'";
DataSet ds = DBAcess.GetDataSet(sql, true);
if (ds.Tables[0].Rows.Count > 0)
{
return a;
}
else
return b;
}
[AjaxPro.AjaxMethod]
public string pwd(string p1, string p2)
{
string a = "一致";
string b = "不一致";
if (p1 == p2)
{
return a;
}
else
return b;
}
}
前台文件 因为代码较长。我只贴出有关的部分。
<asp:Content ID ="reg" ContentPlaceHolderID ="Registerpage" runat ="server" >
<script language="javascript" type="text/javascript">
function textbox()
{
var username=document.getElementById("<%#TextBox1.ClientID%>").value;
RegisterPage.select(username,getGroups_callback } function getGroups_callback(response)
{
document.getElementById("tb").value=response.value
// var dt=response.value; alert(dt);
}
</script>
<asp:Panel ID="Panel1" runat="server" Width="269px" >
<%--个人用户--%>
<table ><tr><td ><%#Global.GetString("RegType")%></td>
<td style="width: 158px"><asp:RadioButtonList ID="SelectType" runat="server" RepeatDirection="Horizontal">
<asp:ListItem/><asp:ListItem />
</asp:RadioButtonList></td>
<td style="width: 158px">
</td>
</tr>
<tr><td><%#Global.GetString("LabName")%></td><td style="width: 158px"><asp:TextBox ID="TextBox1" runat="server"/></td>
<td style="width: 158px"><input id="comit" type="button" value="检测用户名是否" onclick="textbox()"/>
<asp:TextBox ID="tb" runat="server"></asp:TextBox>
</td>
</tr>
现在运行页面后。点击按纽检测用户名老弹出一个对话框说
'document.getElementById()'为空或者不是对象
请大家指点下!谢谢了!