I need to call a webmethod of a webservice asynchronously from code behind of a web page.
In the callback function I need to bind a gridview and render it. I want to partially render that gridview in the callback function in codebehind.
How to implement that?
Is it possible to implement all these in codebehind without using javascript?
There are a couple of options, but basically you need to do something like this:
- Use Visual Studio to build a proxy class to access the web service, using the published WSDL
- Create an async web page, by setting Async=True in the Page directive
- In the Page_Load() method of your code behind, register methods that will start and end the async web service call by creating a PageAsyncTask object and calling RegisterAsyncTask()
- From the method that starts the async task, call the Begin method that was created as part of the proxy class, and return the associated IAsyncResult to the caller
- When the web service call completes, the runtime will call your registered end method. From there, call the End method in the proxy to get the results of the call.
- Databind the results to a GridView on your page.
In case it helps, I walk through a detailed example along these lines in my book, including sample code: Ultra-Fast ASP.NET.