如何使用jquery GET方式请求调用asp.net方法

前台页面

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Third.aspx.cs" Inherits="jquery_Learning.Third" %> 

-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 

http://www.w3.org/1999/xhtml" > 
server"> 
    无标题页 
     
     
 
 
    
form1" runat="server">
btn1" type="button" value="GET" />
btn2" type="button" value="POST" />

 

后台页面代码Default.aspx.cs

using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;

namespace jquery_Learning
{
    public partial class _Default : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            char method = Convert.ToChar(HttpContext.Current.Request.QueryString["m"]);
            if (method.ToString() == null )
            {
                method = Convert.ToChar(HttpContext.Current.Request.Form["m"]);
            }
            HttpContext.Current.Request.ContentType = "text/plain";
            switch (method)
            {
                case 'a':
                    HttpContext.Current.Response.Write("a");
                    break;
                case 'b':
                    HttpContext.Current.Response.Write("b");
                    break;
            }
            Response.End();
        }
    }
}

你可能感兴趣的:(jquery,ajax)