views:

24

answers:

1

How do I differentiate between two triggers that can both POST callbacks to the page during OnLoad? The controls themselves will automatically trigger their callback handlers, but that is too late.

The background on my issue is probably irrelevant, but ... I am creating an ASP.NET web page and I have two controls on the page that can trigger a callback, a "change active tab" event from my DevExpress ASPxTabControl and a "update" button that changes some settings. I only want to load the contents on the active tab because the tabs are filled with too-heavy computations and so forth. For various reasons, this loading must happen in OnLoad() unless the tab is the one firing the callback, in which case it should happen (only) during the "active tab changed" event.

+1  A: 

Maybe you can read the hidden fields associated with callbacks:

  • __CALLBACKID (which stores the ID of the ICallbackEventHandler control that will be recieving the callback)
  • __CALLBACKPARAM (which stores the callback's eventArgument).

You can read these values like this:

Request["__CALLBACKID"]
Request["__CALLBACKPARAM"]

If you decide to use the EventArgument, then you would have to put some value into it that you would be able to read at this point, to give you the issuing control.

Gabriel McAdams
My __EVENTTARGET always appears to be string.Empty. Is that just for PostBacks that aren't callbacks?
Scott Stafford
Perhaps it is. Maybe you could read the __CALLBACKPARAM value (which is the eventArgument for callbacks) instead (and just put something in it that designates which control issued the callback). I edited my answer to reflect this.
Gabriel McAdams