Q2 2006 SP1 or later
2.0, but it can be reworked for 1.x too
|Visual Studio version
all browsers supported by r.a.d.controls
Some business cases require building a loosely coupled web site that has to be able to trigger AJAX requests from one area and update that area and/or various other areas depending on some conditions. You can achieve that with only one RadAjaxManager on your page that will have its AjaxSettings configured dynamically. There are three tricky moments in such cases:
- describing which control will update which other controls
- finding the initiator and updated controls and adding ajax settings for them
- finding a control to update inside a user control since user controls are not updateable
The examle here loads two user controls. Both implement a simple interface that can be used to get a control that will be updated with Ajax -- an inner <asp:Panel> in our case. That solves the third problem. The second problem can be solved by bubbling events from the control and handling them on the page. We use two event names: RegisterUpdatableControl that will add an AjaxSetting used to update the control itself; AreaUpdate -- just a name that is used to distinguish when to add AjaxSettings for the other area controls. This can be used to implement the rules mentioned above -- you can use the initiator control and command name to define different AjaxSettings that suit your needs.
Here is the list of the most interesting parts of the code:
- The IUpdatableControl interface and its implementation in the user control that returns the inner panel.
- The RaiseBubbleCommand call in the user control Page_Load event that registers the control for Ajax.
- The RaiseBubbleCommand in the Button2_Click event handler that will request updating both controls. Normally, only one of the controls will be updated.
- The OnBubbleEvent page method override that adds the AjaxSettings according to the initiator control and event name.