复制代码代码如下:
<! Doctype html public "-// w3c // dtd xhtml 1.0 transitional // pt" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-bransitional.dtd">
<html xmlns = "http://www.w3.org/1999/xhtml">
<head>
<Title> </title>
<script type = "text/javascript" src = "lib/jQuery-1.7.2.min.js"> </script>
<script type = "text/javascript">
$ (function () {
$ ("#btnsubmit"). Clique (function () {
$ .ajax ({
Tipo: "post",
URL: "Handler02.ashx",
Dados: $ ("#frmuserinfo"). Serialize (),
Sucesso: função (resultado) {
$ ("#msg"). html (resultado);
}
});
retornar falso;
});
});
</script>
</head>
<Body>
<form id = "frmuserinfo" action = "#">
<tabela>
<tr>
<Td>
姓名
</td>
<Td>
<input type = "text" id = "txtuserName" name = "txtuserName" />
</td>
</tr>
<tr>
<Td>
密码
</td>
<Td>
<input type = "senha" id = "txtUserpwd" name = "txtuserpwd" />
</td>
</tr>
<tr>
<td colspan = "2">
<input type = "submit" id = "btnsubMit" value = "提交" />
</td>
</tr>
</tabela>
</morm>
<div id = "msg"> </div>
</body>
</html>
复制代码代码如下:
/// <summary>
/// manipulador 的摘要说明
/// </summary>
Handler de classe pública02: ihttphandler
{
/// <summary>
/// 请求处理
/// </summary>
/// <param name = "context"> </amon>
Public void ProcessRequest (contexto httpContext)
{
context.Response.ContentType = "Text/Plain";
// 方式 2 (对应表单序列化)
String userName = context.request.form ["txtuserName"]. tostring ();
string userpwd = context.request.form ["txtUserpwd"]. tostring ();
context.Response.Write (String.Format ("姓名 : {0} , 密码 : : {1}", nome de usuário, userPwd));
context.Response.end ();
}
public bool isreusable
{
pegar
{
retornar falso;
}
}
}