the .apsx page with ajax need to call a handler (.asxh) to get the values and process it
you can put the handler in one location or in the same location as the aspx page that is calling it
the ajax would retrieve the values and send it to the hanlder, in the handler it process the data and can also pass back values to the ajax on the first page
(aspx page)
//Call the page method
$.ajax({
type: "POST",
url: myHandler.ashx,
contentType: "application/json;",
data: dataObject,
dataType: "json",
success: ajaxCallSuccess,
error: ajaxCallFailure
});
(handler page)
<%@ WebHandler Language="C#" Class="myHandler" %>
using System;
using System.Web;
public class myHandler : IHttpHandler
{
public void ProcessRequest(HttpContext context)
{
string strFname = string.empty;
string strLname = string.empty;
context.Response.ContentType = "application/json";
if (!String.IsNullOrEmpty(context.Request.Form["FirstName"]))
{
strFname= Convert.ToString(context.Request.Form["FirstName"]);
}
if (!String.IsNullOrEmpty(context.Request.Form["LastName"]))
{
strLname = Convert.ToString(context.Request.Form["LastName"]);
}
context.Response.Write(HelloWorld(strFname, strLname));
}
public bool IsReusable
{
get { return false; }
}
public string HelloWorld(string fname, string lname)
{
return "Hello World, my name is " + fname + " " + lname;
}
}