Button按钮控件的事件 OnClick="CheckUser()"出错
<scripttype="text/javascript">varxmlhttp;functioncreateXMLHttpRequest(){//如果不是IEif(wi...
<script type="text/javascript">
var xmlhttp;
function createXMLHttpRequest() {
//如果不是IE
if (window.XMLHttpRequest) {
xmlhttp = new XMLHttpRequest();
}
else {
//如果是IE
xmlhttp = new ActiveXObject();
}
}
function CheckUser() {
createXMLHttpRequest();
xmlhttp.onreadystatechange = showMessage();
var url = "HandleUsers.ashx?username=" + document.getElementById("txtName").value;
xmlhttp.open("GET", url, true);
xmlhttp.send(null);
}
function showMessage() {
if (xmlhttp.readyStats == 4) {
if (xmlhttp.status == 200)
document.getElementById("lblMsg").value = xmlhttp.responseText;
}
}
</script>
<asp:TextBox ID="txtName" runat="server"></asp:TextBox>
<asp:Button ID="btnShow" runat="server" Text="显示" OnClick="CheckUser()" />
<asp:Label ID="lblMsg" runat="server" Text="Label"></asp:Label> 展开
var xmlhttp;
function createXMLHttpRequest() {
//如果不是IE
if (window.XMLHttpRequest) {
xmlhttp = new XMLHttpRequest();
}
else {
//如果是IE
xmlhttp = new ActiveXObject();
}
}
function CheckUser() {
createXMLHttpRequest();
xmlhttp.onreadystatechange = showMessage();
var url = "HandleUsers.ashx?username=" + document.getElementById("txtName").value;
xmlhttp.open("GET", url, true);
xmlhttp.send(null);
}
function showMessage() {
if (xmlhttp.readyStats == 4) {
if (xmlhttp.status == 200)
document.getElementById("lblMsg").value = xmlhttp.responseText;
}
}
</script>
<asp:TextBox ID="txtName" runat="server"></asp:TextBox>
<asp:Button ID="btnShow" runat="server" Text="显示" OnClick="CheckUser()" />
<asp:Label ID="lblMsg" runat="server" Text="Label"></asp:Label> 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询