复制代码代码如下:
<!Doctype HTML公共“ - // W3C // DTD XHTML 1.0 Transitional // en”“” http://www.org/tr/tr/xhtml1/dtd/xhtml1-xhtml1-transitional.transitional.dtdd'>
<html xmlns =“ http://www.w3.org/1999/xhtml”>
<头>
<title> </title>
<script type =“ text/javascript” src =“ lib/jquery-1.7.2.2.min.js”> </script>
<脚本类型=“ text/javascript”>
$(function(){
$(“#btnsubmit”)。单击(function(){
$ .ajax({
类型:“ post”,
URL:“ handler02.ashx”,
数据:$(“#frmuserinfo”)。serialize(),
成功:功能(结果){
$(“#msg”)。html(结果);
}
});
返回false;
});
});
</script>
</head>
<身体>
<形式id =“ frmuserinfo” action =“#”>
<表>
<tr>
<td>
姓名
</td>
<td>
<input type =“ text” id =“ txtusername” name =“ txtusername” />
</td>
</tr>
<tr>
<td>
密码
</td>
<td>
<input type =“密码” id =“ txtuserpwd” name =“ txtuserpwd”
</td>
</tr>
<tr>
<td colspan =“ 2”>
<输入type =“ submit” id =“ btnsubmit” value =“提交” />
</td>
</tr>
</table>
</form>
<div ID =“ msg”> </div>
</body>
</html>
复制代码代码如下:
/// <summary>
///处理程序的摘要说明
/// </summary>
公共类Handler02:ihttphandler
{
/// <summary>
///请求处理
/// </summary>
/// <param name =“上下文”> </param>
public void ProcessRequest(httpcontext上下文)
{
context.response.contenttype =“ text/plain”;
//(2 (对应表单序列化)
字符串用户名= context.request.form [“ txtusername”]。toString();
字符串userpwd = context.request.form [“ txtuserpwd”]。
context.response.write(string.format(“姓名
context.response.end();
}
公共布尔可以用来调用
{
得到
{
返回false;
}
}
}