最新下载
热门教程
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
ajax之aspx或ashx页面里进行多次使用
时间:2011-12-02 编辑:简简单单 来源:一聚教程网
前台页面AjaxTest.htm,内容如下
代码如下 | 复制代码 |
http://www.111com.net>
|
后台建立一个Handler.ashx页面 内容如下
代码如下 | 复制代码 |
<%@ WebHandler Language="C#" class="Handler" %> using System; public class Handler : IHttpHandler { //得到前台传过来的command,确定调用哪个方法
} |
如果有多个方法,switch case里的判断将会很多.考虑用更简单的方法.使用反射
代码如下 | 复制代码 |
<%@ WebHandler Language="C#" class="Handler" %> using System; public class Handler : IHttpHandler { // context.Response.Write("hello,"+context.Request["value"].ToString());
} |
使用反射大大简化了程序.
=====================================================
使用aspx页面与ajax交互
新建一个aspx页面 WebMethod.aspx
将WebMethod.aspx页里的多余部分删除,只保留
代码如下 | 复制代码 |
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="WebMethod.aspx.cs" Inherits="WebMethod" %> |
这一条语句
WebMethod.aspx.cs内容如下
代码如下 | 复制代码 |
using System; using System.Web.Services; public partial class WebMethod : System.Web.UI.Page test.html页面与WebMethod.aspx页面进行ajax交互 test.html页面内容
|
-
上一个: asp.net浏览器缓存操作
相关文章
- C#复制数组的两种方式及效率比较解读 10-24
- ASP.NET Identity用法解析 10-24
- ASP.NET MVC使用Identity增删改查用户介绍 10-24
- C语言中atoi函数模拟实现介绍 10-18
- .Net反向代理组件Yarp用法介绍 10-10
- .NET使用YARP通过编码方式配置域名转发实现反向代理教程 10-10