62,041
社区成员
发帖
与我相关
我的任务
分享
<script type="text/javascript">
var xmlhttp;
var result;
function btn_logn_Clock() {
var userName = document.getElementById("username").value;
var userPwd = document.getElementById("password").value;
xmlhttp = window.XMLHttpRequest ? new XMLHttpRequest() : new ActiveXObject("Microsoft.XMLHTTP");
var data = "username=" + encodeURIComponent(userName)
+ "&password=" + encodeURIComponent(userPwd);
xmlhttp.open("Post", "Default2.aspx", true);
xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
xmlhttp.onreadystatechange = function () {
if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
result = xmlhttp.responseText;
}
}
xmlhttp.send(data);
}
</script>
protected void Page_Load(object sender, EventArgs e)
{
string userName = string.Empty;
string password = string.Empty;
userName = Request.Form["username"];
password = Request.Form["password"];
Response.Write("姓名:’" + userName + "'<br/> 密码:" + password);
Response.End();
}
<!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 id="Head1" runat="server">
<title></title>
<script type="text/javascript">
var xmlhttp;
var result;
function btn_logn_Clock() {
var userName = "张三";
var userPwd = "12345";
xmlhttp = window.XMLHttpRequest ? new XMLHttpRequest() : new ActiveXObject("Microsoft.XMLHTTP");
var data = "username=" + encodeURIComponent(userName)
+ "&password=" + encodeURIComponent(userPwd);
xmlhttp.open("Post", "Default.aspx", true);
xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
xmlhttp.onreadystatechange = function() {
if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
result = xmlhttp.responseText;
alert(result);
}
}
xmlhttp.send(data);
}
</script>
</head>
<body>
<form id="form1" runat="server">
<input type="button" value="OK" onclick="btn_logn_Clock()" />
</form>
</body>
</html>
Default.aspx.cs:
protected void Page_Load(object sender, EventArgs e)
{
string userName = string.Empty;
string password = string.Empty;
userName = Request.Form["username"];
password = Request.Form["password"];
if (userName!=null)
{
Response.Write("姓名:’" + userName + "'<br/> 密码:" + password);
Response.End();
}
}