At the top of page, you import the required namespaces by using the Import directive. After that we use the implements directive to implement the ICallbackEventHandler interface. This interface has a method named RaiseCallbackEvent that must be implemented to make the callback work. |
<%@ implements interface=”System.Web.UI.ICallbackEventHandler” %> |
The signature of the RaiseCallbackEvent method is as follows. |
void ICallbackEventHandler.RaiseCallbackEvent(string eventArgs) |
As you can see from the above, the RaiseCallbackEvent method takes an argument of type string. If you need to pass values to the server-side method, you should use this string argument. Inside the |
RaiseCallbackEvent method, you store the supplied event argument in a local private variable for future use. |
void ICallbackEventHandler.RaiseCallbackEvent(string eventArgument) { |
_callbackArg = eventArgument; |
} |
After that, you override the GetCallbackResult() method as shown below. |
string ICallbackEventHandler.GetCallbackResult() { |
int value = Int32.Parse(_callbackArg); return GetEmployeeDetails(value); |
} |
The GetCallbackResult() method is the one that is responsible for returning the output of the server- side execution to the client. Inside the GetCallbackResult() method, you first convert the supplied employee ID into an integer type and then invoke a function named GetEmployeeDetails passing in the employee ID as an argument. |
int value = Int32.Parse(eventArgs); return GetEmployeeDetails(value); |
As the name suggests, the GetEmployeeDetails() method retrieves the details of the employee and returns that information in the form of an XML string. This method starts by retrieving the connection string from the web.config file by using the following line of code. |
learn guitarphysics learnteliphonyxmlphysicsenjoylife