该页面的HTML如下,实现用户点击连接,把用户名发回服务端检测是否存在,在把信息传回
Label控件显示出来!!!可是点击连接后,什么都没有显示出来,各位帮我看看我的代码哪里出错了谢谢!!!!!帮我
改改<%@ Page language="c#" Codebehind="WebForm1.aspx.cs" AutoEventWireup="false" Inherits="qzgd1.WebForm1" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
<HEAD>
<title>WebForm1</title>
<script language="javascript">function CheckUser()
{
//创建ActiveXObject
try {
xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
} catch(e) {
xmlHttp = new XMLHttpRequest();
} xmlHttp.onreadystatechange = function() {
if (xmlHttp.readyState == 4) {
if (xmlHttp.status == 200) {
var data = xmlHttp.responseText;
document.getElementById("label").value = data;
}
}
} xmlHttp.open("GET","WebForm1.aspx?strUserID="+document.getElementById("TextBoxUserName").value);
xmlHttp.send(null);
} </script>
<meta name="GENERATOR" Content="Microsoft Visual Studio .NET 7.1">
<meta name="CODE_LANGUAGE" Content="C#">
<meta name="vs_defaultClientScript" content="JavaScript">
<meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5">
</HEAD>
<body>
<form id="Form1" method="post" runat="server">
<FONT face="宋体">
<DIV id="label" style="DISPLAY: inline; WIDTH: 70px; HEIGHT: 15px" ms_positioning="FlowLayout">Label</DIV>
<INPUT type="text" id="TextBoxUserName"> </FONT><a href="javascript:CheckUser();">
d</a>
</form>
</body>
</HTML>
该页面的.CS代码
string strUserID = "";
string strUserName = ""; if (Request.QueryString.Keys.Count > 0 && Request.QueryString["strUserID"].Length > 0)
{
strUserID = Request.QueryString["strUserID"].ToString();
} //通过strUserID从数据库取得strUserName
Response.Write(strUserName);
//完成并马上关闭。以免传入多余的数据。
Response.Flush();
Response.Close();
Label控件显示出来!!!可是点击连接后,什么都没有显示出来,各位帮我看看我的代码哪里出错了谢谢!!!!!帮我
改改<%@ Page language="c#" Codebehind="WebForm1.aspx.cs" AutoEventWireup="false" Inherits="qzgd1.WebForm1" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
<HEAD>
<title>WebForm1</title>
<script language="javascript">function CheckUser()
{
//创建ActiveXObject
try {
xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
} catch(e) {
xmlHttp = new XMLHttpRequest();
} xmlHttp.onreadystatechange = function() {
if (xmlHttp.readyState == 4) {
if (xmlHttp.status == 200) {
var data = xmlHttp.responseText;
document.getElementById("label").value = data;
}
}
} xmlHttp.open("GET","WebForm1.aspx?strUserID="+document.getElementById("TextBoxUserName").value);
xmlHttp.send(null);
} </script>
<meta name="GENERATOR" Content="Microsoft Visual Studio .NET 7.1">
<meta name="CODE_LANGUAGE" Content="C#">
<meta name="vs_defaultClientScript" content="JavaScript">
<meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5">
</HEAD>
<body>
<form id="Form1" method="post" runat="server">
<FONT face="宋体">
<DIV id="label" style="DISPLAY: inline; WIDTH: 70px; HEIGHT: 15px" ms_positioning="FlowLayout">Label</DIV>
<INPUT type="text" id="TextBoxUserName"> </FONT><a href="javascript:CheckUser();">
d</a>
</form>
</body>
</HTML>
该页面的.CS代码
string strUserID = "";
string strUserName = ""; if (Request.QueryString.Keys.Count > 0 && Request.QueryString["strUserID"].Length > 0)
{
strUserID = Request.QueryString["strUserID"].ToString();
} //通过strUserID从数据库取得strUserName
Response.Write(strUserName);
//完成并马上关闭。以免传入多余的数据。
Response.Flush();
Response.Close();
自己在js中用alert(data)调试下