1. To have the AjaxPo.net framework set, click find>
2. Right-click the project name in ASP.net and add the Asp.net folder. Create a Bin folder.
3. Right-click the BIN folder and select Add reference from it. A dialog box will be displayed. Find the specified AjaxPro. dll or AjaxPro.2.dll and add it.
4. Open the WebConfig file. Add the following content to the <system. web> </system. web> node:
Reference content is as follows: <HttpHandlers> <Add verb = "POST, GET" path = "ajaxpro/*. ashx" type = "AjaxPro. AjaxHandlerFactory, AjaxPro.2"/> </HttpHandlers> |
NOTE: If AjaxPro. dll is referenced, the last 2 will not be included. For example: AjaxPro. AjaxHandlerFactory, AjaxPro
5. open the file for creating the server method. Here is Default. aspx. Open the background code file: Default. aspx. cs.
Add the following to Page_Load:
Reference content is as follows: Protected void Page_Load (object sender, EventArgs e) { Utility. RegisterTypeForAjax (typeof (_ Default); // Add it for the front-end code to call related methods } |
6. define the methods to be called in js, such:
Reference content is as follows: [AjaxMethod] // required. Public DataSet GetAllNews () { NewsPublish wsNP = new NewsPublish (); Return wsNP. GetAllNews (); } |
7. This can be referenced in front-end JS.
_ Default. GetAllNews (GetAllNews_callback) // _ Default indicates the Class Name of the method. GetAllNews_callback processes the returned data.