复制代码代码如下:
<! DocType html public "-// w3c // dtd xhtml 1.0 Transitional // en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transicional.dtd ">
<html xmlns = "http://www.w3.org/1999/xhtml">
<Evista>
<title> </title>
<script type = "text/javaScript" src = "lib/jQuery-1.7.2.min.js"> </script>
<script type = "text/javaScript">
$ (function () {
$ ("#btnsubmit"). Click (function () {
$ .AJAX ({
Tipo: "Publicar",
URL: "Handler02.ashx",
Datos: $ ("#frmuserInfo"). Serialize (),
éxito: function (resultado) {
$ ("#msg"). html (resultado);
}
});
devolver falso;
});
});
</script>
</ablo>
<Body>
<Form id = "frmuserinfo" action = "#">
<Table>
<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">
<input type = "Subt" id = "btnsubmit" value = "提交" />
</td>
</tr>
</table>
</form>
<div id = "msg"> </div>
</body>
</html>
复制代码代码如下:
/// <summary>
/// manejador 的摘要说明
/// </summary>
Handler de clase pública02: ihttphandler
{
/// <summary>
/// 请求处理
/// </summary>
/// <param name = "context"> </param>
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}", username, userPwd));
context.Response.end ();
}
Público bool isreusable
{
conseguir
{
devolver falso;
}
}
}