最新下载
热门教程
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
ajax之aspx或ashx页面里进行多次使用
时间:2022-06-25 03:08:38 编辑:袖梨 来源:一聚教程网
前台页面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页面内容
|
相关文章
- 光遇5.8季节蜡烛在哪里 光遇5月8日季节蜡烛位置攻略 05-08
- 光遇5.8肉桂卷代币在哪里 光遇5月8日大耳狗联动代币收集攻略 05-08
- 光遇5.8大蜡烛在哪里 光遇5月8日大蜡烛位置攻略 05-08
- 光遇5.8免费魔法有什么 光遇5月8日免费魔法收集攻略 05-08
- 崩坏星穹铁道2.2有什么更新 崩铁2.2版本更新内容介绍 05-08
- OKE交易所官网下载2024版 05-08