Talking about the client without refreshing the remote call, its benefits need not be more than words. The implementation of this method, in addition to the popular asynchronous loading of IFrame in the early years, is now more based on Javascript+xmlhttprequest object technology, such as the heyday of Ajax. And here we introduce the asp.net itself to the client remote invocation support-client callback (read Diao), of course, its essence is xmlhttprequest. Similar posts on the internet have been broken, if it is said that the addiction, you can do their own to see how experts say.
Creating a ASP.net page that implements a client callback must perform the following actions:
• Implement ICallbackEventHandler interface. You can add this interface declaration to any ASP.net web page.
• Implement the RaiseCallbackEvent interface method. This method will be invoked by the callback to perform some logical processing.
• Implement the GetCallbackResult interface method. This method returns a string to the Clientcallback function
Note: The method that implements the interface must be public, otherwise it cannot be invoked remotely.
Additionally, the page must contain three client script functions that perform the following actions:
• A function call helper method that executes the actual request to the server. In this function, you can first execute the custom logic to prepare the event arguments, and then you can send a string as a parameter to the server-side callback event handler.
• Another function is called by the result of the server code that handles the callback event and receives the result, while the string representing the result is accepted. The function is the Clientcallback function described above.
• The third function is the Helper function that executes the actual request to the server, which is automatically generated by ASP.net when a reference to this function is generated using the GetCallbackEventReference method in server code.
I have done a simple example here, with only one webform, the interface is as follows:
Implement, enter the text in the text box, click the "Server echo" button, echo the result display text box input.