Telerik RadAjax provides the ability to call web services and retrieve information via AJAX requests. For this purpose there is a special control in Telerik RadAjax controls suite called RadAjaxServiceManager. You need to drag the control from the web form to your toolbox and fill the Services collection. This is a collection of Paths to different web services. You can set relative or absolute paths to the services. The only limitation is that these services MUST be within your Web Application or domain.

Setup Web.Config
First of all in order to use WebServices in Telerik RadAjax, you should modify the web.config file for your application and add the following configuration element inside <system.web> tag:
| web.config |
Copy Code |
|
<webServices> <protocols> <add name="HttpPost"/> </protocols> </webServices> |
Setup service invocation
Once you have set the services, there are two ways for their invocation:
In both cases you need to write a custom JavaScript code that will handle the received response. Telerik RadAjax will generate automatically a proxy method, which has the same name as the WebService method. It will accept two parameters: ServiceCompleteCallback and ServiceErrorCallback. These two parameters correspond to two JavaScript functions. The first one, ServiceCompleteCallback will be executed when in case of successful WebService method execution. The second one, ServiceErrorCallback will be executed in case of failure, so you can use it to display a friendly error message. You should define the bodies of these callback functions in your script block using the following signatures:
| Script |
Copy Code |
|
function ServiceCompleteCallback(ResponseAsJSON, ResponseAsXml, ResponseAsText) { // write your code here... }
function ServiceErrorCallback(args) { // display a friendly error message... } |
See Also