Presentation is loading. Please wait.

Presentation is loading. Please wait.

Www.binaryspectrum.com ASP.Net ICallback Vijayalakshmi G M Senior Trainer Binary Spectrum.

Similar presentations


Presentation on theme: "Www.binaryspectrum.com ASP.Net ICallback Vijayalakshmi G M Senior Trainer Binary Spectrum."— Presentation transcript:

1 www.binaryspectrum.com ASP.Net ICallback Vijayalakshmi G M Senior Trainer Binary Spectrum

2 www.binaryspectrum.com Topics ASP.Net – Client Callback ICallback Implementation ICallback Example

3 www.binaryspectrum.com ASP.Net ICallback - Introduction

4 www.binaryspectrum.com ASP.Net – Postback V/S Callback Postback –Recreates the web page and controls for Entire page and returns the Entire script to the client. –Works based on Synchronized processing model [User should wait till the page is refreshed]. –Huge data gets transferred from Client to Server or vice-versa. Callback –Recreates only the part of the page and control and respond to the client. –Works based on Asynchronous processing model [User can continue with another job]. –Less data gets transferred from client and server.

5 www.binaryspectrum.com ASP.Net – Client Callback Feature provided by ASP.Net Used to avoid full post back in the asp.net page. Good Alternative to Ajax Update Panel. Definition “Client Callback provides us a way to call a server side code/method asynchronously and fetch some new data without page refresh”

6 www.binaryspectrum.com Callback process Flow

7 www.binaryspectrum.com ASP.Net – Client Callback 1.Client Callback is initiated from JavaScript from client browser. 2.Result will be displayed on the client browser after the required modification from Server.

8 www.binaryspectrum.com How to implement Client Callback Server side: –Implement interface ICallbackEventHandler on any page or control where implemented. –Need to implement two methods RaiseCallbackEvent and GetCallbackResult provided by the interface ICallbackEventHandler. –RaiseCallbackEvent event is called to perform the Callback on server. –GetCallbackResult event returns the result of the callback.

9 www.binaryspectrum.com How to implement Client Callback Client side: –Javascript function registered with the Server to initiate a client call. –It takes one parameter to pass the value to the server. –Another JavaScript function to return the callback result. –Helper function which makes actual request to the server [automatically generated by ASP.NET when you generate a reference to this function by using the GetCallbackEventReference method in server code.]

10 www.binaryspectrum.com ICallback - Implementation

11 www.binaryspectrum.com Steps : To Implement Callbacks 1.Use ICallbackEventHandler[ System.Web.UI Namespace] Interface. Implement this interface on Page or a Control.

12 www.binaryspectrum.com Steps : To Implement Callbacks 2. Server side function public void RaiseCallbackEvent(String eventArgument) – Automatically called whenever there is a callback.

13 www.binaryspectrum.com Steps : To Implement Callbacks 2. Server side function public String GetCallbackResult() – returns the output to the client.

14 www.binaryspectrum.com Steps : To Implement Callbacks 2. GetCallbackEventReference() – Register Client side script at Page load. we need to create a Callback reference, that is the Client side method that is called, after finishing the callback, and assign that reference in the method that initiates callback from Client.

15 www.binaryspectrum.com GetCallbackEventReference() - Method Control - The server Control that handles the client callback.Control Argument - An argument passed from the client script to the server. clientCallback - The name of the client event handler that receives the result of the successful server event. Context - Client script that is evaluated on the client prior to initiating the callback.

16 www.binaryspectrum.com GetCallbackEventReference() - Method

17 www.binaryspectrum.com Steps : To Implement Callbacks 3. Client side function Javascript function – to raise a client callback. event.

18 www.binaryspectrum.com Steps : To Implement Callbacks 3. Client side function Javascript function – which will handle the response from the server. This function will be called automatically after GetCallbackResult().

19 www.binaryspectrum.com Steps : To Implement Callbacks 4. HTML Form

20 www.binaryspectrum.com Client Callback v/s Postback

21 www.binaryspectrum.com Callback – When and Where to use Light Action and gives better performance over update panel. It should be used only for display purpose.

22 www.binaryspectrum.com Callback – Drawbacks Cross browser support –Callbacks are supported by Internet Explorer, Firefox and other Mozilla-compliant browsers. Not all the browsers support partial page updation. Script code should strictly follow the W3 DOM standards Server's Response Delivery Format –Server responds with String data, works well with small amount of data. [becomes problematic with large complex data]. Problem with multiple callbacks

23 www.binaryspectrum.com Resource

24 www.binaryspectrum.com Icallback - Resources http://www.codeproject.com/Articles/137899/ Exploring-Client-Callback.aspx?display=Mobilehttp://www.codeproject.com/Articles/137899/ Exploring-Client-Callback.aspx?display=Mobile http://rameshch.wordpress.com/2009/02/12/u sing-icallbackeventhandler-in-aspnet/http://rameshch.wordpress.com/2009/02/12/u sing-icallbackeventhandler-in-aspnet/ http://www.dotnettwitter.com/2011/06/imple menting-icallbackeventhandler-in.htmlhttp://www.dotnettwitter.com/2011/06/imple menting-icallbackeventhandler-in.html

25 www.binaryspectrum.com Thank you


Download ppt "Www.binaryspectrum.com ASP.Net ICallback Vijayalakshmi G M Senior Trainer Binary Spectrum."

Similar presentations


Ads by Google