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.