English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

Implementation method of Ajax client-side asynchronous call to server-side (js call cs file)

The usage of ajax, the way to call cs files in js, the steps are as follows

(1)Download ajax.dll and add it as a reference to the project.

(2)Add <add verb="POST,GET" path="ajax" in the <httpHandlers> node of the project's webconfig./*.ashx" type="Ajax.PageHandlerFactory, Ajax"/>Node

(3)Add Ajax.Utility.RegisterTypeForAjax(typeof(ClassName)) in the pageload method of the aspx page. Here, ClassName is the class name of the current cs file.

(4)All methods that need to be called in js and written in cs need to be added with [Ajax.AjaxMethod()] in front of them. If you want to call session, you need to write it as: [Ajax.AjaxMethod(HttpSessionStateRequirement.Read)].

(5In the js method, write var address = ClassName.MethodName('parameter').value;   //ClassName is the class name, MethodName is the method name, and the parameter passed in is parameter.

The above article on the implementation method of Ajax client asynchronous call to the server (js call cs file) is all the content that the editor shares with everyone. I hope it can give you a reference, and I also hope that everyone will support the Shouting Tutorial more.

Declaration: The content of this article is from the Internet, and the copyright belongs to the original author. The content is contributed and uploaded by Internet users spontaneously. This website does not own the copyright, has not been manually edited, and does not assume any relevant legal liability. If you find any content suspected of copyright infringement, please send an email to: notice#oldtoolbag.com (Please replace # with @ when sending an email to report abuse, and provide relevant evidence. Once verified, this site will immediately delete the content suspected of infringement.)

You May Also Like