Client does not flush the calling server program

Source: Internet
Author: User

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.