- PrepareCallbackEvent
- RenderCallbackResult
void ICallbackEventHandler.PrepareCallbackEvent(string eventArgument)
{
this._eventArg = eventArgument;
}
string ICallbackEventHandler.RenderCallbackResult()
{
if (this._eventArg.StartsWith("1:"))
{
//--strips away the command
this._eventArg = this._eventArg.Substring(2);
//--get city and state based on Zipcode
switch (this._eventArg)
{
case "95472":
return "Sebastopol,CA";
case "02140":
return "Cambridge,MA";
default:
throw (new Exception("ZipCode not valid!"));
}
}
else if (this._eventArg.StartsWith("2:"))
{
//--strips away the command
this._eventArg = this._eventArg.Substring(2);
//--get states and cities related to country
switch (this._eventArg)
{
case "Sing":
return "Singapore,";
case "US":
return "Alabama,California,Maryland,Massachusetts,New York,Oklahoma,Wisconsin,";
case "UK":
return "Birmingham,Cambridge,Christchurch,Leeds,Sheffield,";
default:
return "";
}
}
else
{
return "Command not recognized";
}
}
In essence, the two events above replace the original function that handled the RaiseCallbackEvent event. The rationale for the changes is to ensure callbacks work with asynchronous data sources.
For VB2005 readers, it should not be difficult to modify the original code in the book. Thanks, Cindy, for pointing that out to me!
No comments:
Post a Comment