87,907
社区成员
发帖
与我相关
我的任务
分享
var xmlHttp=false;
try
{
xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
}
catch(e)
{
try
{
xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
}
catch(e2)
{
xmlHttp=false;
}
}
if(!xmlHttp && XMLHttpRequest!='undefined')
{
xmlHttp=new XMLHttpRequest();
}
<!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>无标题页</title>
<script type="text/javascript">
var xmlhttp;
function Validation()
{
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
var name=document.getElementById("Text1");
xmlhttp.open("Post","AJAXProcessor.aspx?name="+name.value);
xmlhttp.onreadystatechange=OnMessageBack;
xmlhttp.send(null);
}
function OnMessageBack()
{
if(xmlhttp.readystate==4&&xmlhttp.status==200)
{
document.write(xmlhttp.responsetext);
}
}
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<input id="Text1" type="text" /><input id="Button1" type="button" value="button" onclick="Validation();" />
</div>
</form>
</body>
</html>
string ReAction = this.Request.QueryString["Action"];//这是你从页面上请求来的值
SqlConnection Conn = new SqlConnection(“连接字符串");
Conn.Open();
SqlCommand Cmd = new SqlCommand();
Cmd.Connection = Conn;
Cmd.CommandText = "更新字符串";
Cmd.ExecuteNonQuery();
Conn.Close();