Ajax application method summary

Source: Internet
Author: User

Note: Ajax serves as a bridge between the front-end and the back-end. You can call the back-end method at the front-end.

The dll can be downloaded from the Ajax. dll file.

Configuration:

Step 1: Configure in webconfig:

<System. Web>
<Httphandlers>
<Add verb = "post, get" Path = "ajax/*. ashx" type = "Ajax. pagehandlerfactory, Ajax"> </Add>
</Httphandlers>

 

Step 2: register on the referenced page:

Ajax. Utility. registertypeforajax (typeof (addnews ));

Addnews is the name of the page.

 

Step 3: declare before the called method:

 

When you do not need to perform session operations: [Ajax. ajaxmethod ()]

When session operations are required: [Ajax. ajaxmethod (Ajax. httpsessionstaterequirement. readwrite)]

 

Application:

Step 1: Define the background method:

/// Obtain the category
/// </Summary>
/// <Param name = "E"> </param>
[Ajax. ajaxmethod ()]
Public dataset getcatogory ()
{
Database. dboperation DB = new database. dboperation ();

String strsql = "select catogoryname from tb_newscatogory order by ID ";
DS = new dataset ();
DS = dB. getdataset (strsql );
Return Ds;
}

 

Step 2: Call JS at the front end:

VaR DS = addnews. getcatogory (). value;

Addnews is the name of the registration page

 

Note:

1. The JS reference statement must be in the <form>... </form> block.

2. the method defined in the background must be of the Public type.

 

 

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.