62,046
社区成员
发帖
与我相关
我的任务
分享
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="ajax.aspx.cs" Inherits="ajax" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>ajax</title>
<script type ="text/javascript" >
var xmlHttp;
function createXMLHttpRequest(){
if (window.ActiveXObject)
xmlHttp =new ActiveXObject ("Microsoft.XMLHTTP");
else if (window.XMLHttpRequest )
xmlHttp =new XMLHttpRequest();
}
function startRequest() {
createXMLHttpRequest();
xmlHttp.onreadystatechange = state_Change;
xmlHttp.open("GET", "Handler2.ashx", true);
xmlHttp.send(null);
}
function state_Change() {
if (xmlHttp.readyState == 4 && xmlHttp.status == 200) {
//alert("服务器返回:" + xmlHttp.responseText)
document.getElementById("Label1").innerHTML=xmlHttp.responseText;
}
}
function checkuser(){
createXMLHttpRequest();
xmlHttp.onreadystatechange = state_Change;
var username=document.getElementById("Text1").value;
xmlHttp.open("GET", "Handler6.ashx?user="+username, true);
xmlHttp.send(null);
}
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
图书:<input id="Text1" type="text" onblur="checkuser();" /><asp:Label ID="Label1" runat="server"
></asp:Label><br />
<asp:Button ID="Button2" runat="server" Text="Button" onclick="Button2_Click" />
</div>
</form>
</body>
</html>
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
public partial class ajax : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button2_Click(object sender, EventArgs e)
{
string str1 = TextBox1.Text;
Response.Write(Label1.Text);
}
}
<asp:Label ID="Label1" runat="server">