Suddenly seen in the project, The Ajax in ASPX can access the methods in the Aspx.cs, feel very novel, perhaps LZ Shaojianduoguai, however, really have found the new world like that kind of excitement, you may know what this means, learned this way, on behalf of you, you can build fewer pages, less ashx, less ... Can you not be excited? In the LZ's impression, Ajax is generally associated with the general handler, request another ASPX page does not say, and the request of their own Codebehind method is really rarely seen, here record, perhaps there is the same as I do not know friends, I hope to help you. It's just that Ajax can access the WebMethod feature in WebService, and it's not possible to access the method of adding WebMethod in aspx. Thanks for knowing now.
Ajax Configuration
Test: Simulate an addition operation in the second grade of primary school, pass the value to the Add method in Default.aspx.cs by Ajax, and return the result by this method.
Default.aspx
How to use Ajax here is not much to say.
<%@ Page language= "C #" autoeventwireup= "true" codebehind= "Default.aspx.cs" inherits= "Wolfy.AjaxSelf.Default"% > <! DOCTYPE html>
Default.aspx.cs
Using System;
Using System.Collections.Generic;
Using System.Linq;
Using System.Web;
Using System.Web.Services;
Using System.Web.UI;
Using System.Web.UI.WebControls;
Namespace Wolfy.ajaxself
{public
partial class Default:System.Web.UI.Page
{
protected void Page_ Load (object sender, EventArgs e)
{
}
[WebMethod] public
static int Add (int num1, int num2)
{ return NUM1 + num2; }
}
}
Test results
More Wonderful content: http://www.bianceng.cnhttp://www.bianceng.cn/webkf/ajax/