复制代码代码如下::
<! DocType html public "-// w3c // dtd xhtml 1.0 transitional // en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transsitional.dtd">
<html xmlns = "http://www.w3.org/1999/xhtml">
<kopf>
<title> </title>
<script type = "text/javaScript" src = "lib/jQuery-1.7.2.min.js"> </script>
<script type = "text/javaScript">
$ (function () {
$ ("#btnsubmit"). Click (function () {
$ .ajax ({{{
Typ: "Post",
URL: "Handler02.ashx",
Daten: $ ("#frmuserinfo"). serialize (),
Erfolg: Funktion (Ergebnis) {
$ ("#msg"). HTML (Ergebnis);
}
});
false zurückgeben;
});
});
</script>
</head>
<body>
<form id = "frMuserinfo" action = "#">
<tabelle>
<tr>
<td>
姓名
</td>
<td>
<input type = "text" id = "txtusername" name = "txtusername" />
</td>
</tr>
<tr>
<td>
密码
</td>
<td>
<input type = "password" id = "txtuserpwd" name = "txtUserpwd" />
</td>
</tr>
<tr>
<td colspan = "2">
<Eingabe type = "Senden" id = "btnsubmit" value = "提交" />
</td>
</tr>
</table>
</form>
<div id = "msg"> </div>
</body>
</html>
复制代码代码如下::
/// <summary>
/// Handler 的摘要说明
/// </summary>
öffentlicher Klassenhandler02: ihttphandler
{
/// <summary>
/// 请求处理
/// </summary>
/// <param name = "context"> </param>
public void processRequest (HTTPContext -Kontext)
{
context.Response.contentType = "text/plain";
// 方式 2 (对应表单序列化)
String userername = context.request.form ["txtusername"]. toString ();
String userpwd = context.request.form ["txtUserPWD"]. toString ();
context.Response.write (string.format ("姓名 : {0} , 密码 : {1}", Benutzername, userPWD));
context.Response.end ();
}
öffentlich bool isreusable
{
erhalten
{
false zurückgeben;
}
}
}