There are three kinds of methods I have used:
1 Add a hidden button to the page, define the event, and then execute the $ ("#隐藏btnID") of JS. Click () to perform the background method
2 Use Ajaxpro to perform
3 using the Ajax URL: page address/(static) method name to perform
In this approach, the method must require static, so for example, in the _default page, for example,
Copy Code code 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 (); You cannot use RESULT,ABC if you do not instantiate it
Nostaticfun NSF = new Nostaticfun (); You cannot use test if you do not instantiate
D.result = Nsf.test ();
D.result = D.ABC;
return d.result;
}
}
public class Nostaticfun
{
public int test ()
{
return 2;
}
}
In this example, I'm tagging, and I want to talk to you about what better way to do it, or how you're going to apply it.