I have used three methods:
1. Add a hidden button to the page, define the event, and execute $ ("# Hide btnID"). click () of js to execute the background method.
2. Use ajaxPro for execution
3. Use the url of ajax: page address/(static) method name for execution.
In this method, the method must be static. For example, on the _ default page, the example is as follows:
Copy codeThe Code is as follows:
Public partial class _ Default: System. Web. UI. Page
{
Static int sVar = 1;
Int abc = 3;
Int result;
[WebMethod]
Public static string AjaxGetMethod ()
{
SVar = 2; // static variables can be called directly
_ Default d = new _ Default (); // if it is not instantiated, result, abc cannot be used.
NoStaticFun nsf = new NoStaticFun (); // test is unavailable if it is not instantiated.
D. result = nsf. test ();
D. result = d. abc;
Return d. result;
}
}
Public class NoStaticFun
{
Public int test ()
{
Return 2;
}
}
In this example, I have made a note. I 'd like to discuss with you any other better methods, or how you apply these methods.