No need to call ajax, there are a variety of methods such as (webservice (. asmx), ashx page, and some call the [WebMethod] method)
Now we are talking about ajax calling the [WebMethod] method.
<% @ Page Language = "C #" AutoEventWireup = "true" CodeBehind = "WebForm3.aspx. cs" Inherits = "test2.WebForm3" %> <! DOCTYPE html PUBLIC "-// W3C // dtd xhtml 1.0 Transitional // EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
Using System; using System. collections. generic; using System. linq; using System. web; using System. web. UI; using System. web. UI. webControls; using System. xml; using System. web. services; namespace test2 {public partial class WebForm3: System. web. UI. page {protected void Page_Load (object sender, EventArgs e) {}// must be a static method [WebMethod] public static int add (int num1, int num2) {return num1 + num2 ;}}}
Running result:
For more details, I will summarize the three interaction methods!