Ajax call back-end method Everyone can discuss the next _ajax related

Source: Internet
Author: User
Tags call back
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.
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.