There are cases where we need to set the RadAjaxManager with a lot of controls in order to get the right dynamic updates. Consider the following code:
(RAMPUC=RadAjaxManagerProxy for UserControl)
It's basic and effective, but wordy and redundant, right? And a complex page can have a lot more of those lines. So here's an alternative:
And here's the method:
Assuming that in this case I do want Progress1 to be active for all updates, from a readability perspective do other people here find the alternative preferable to the original? Or am I just adding more code where it's not necessary and abstracting/refactoring into even more complexity?
More importantly, this is what I came up with to try to streamline the code a bit, and make adding new trigger/update relationships easier, but is there a better, or more elegant way to do what I'm doing here?
Opinions? Thanks!
RAMPUCScheduleEdit.AjaxSettings.AddAjaxSetting(fShiftQty , fBalance , Progress1);
RAMPUCScheduleEdit.AjaxSettings.AddAjaxSetting(fShiftQty , fHours , Progress1);
RAMPUCScheduleEdit.AjaxSettings.AddAjaxSetting(fHours , fShiftQty , Progress1);
RAMPUCScheduleEdit.AjaxSettings.AddAjaxSetting(fHours , fBalance , Progress1);
RAMPUCScheduleEdit.AjaxSettings.AddAjaxSetting(fCrewSize , fCrewTotal , Progress1);
RAMPUCScheduleEdit.AjaxSettings.AddAjaxSetting(fCrewSize , fCrewTemps , Progress1);
RAMPUCScheduleEdit.AjaxSettings.AddAjaxSetting(fCrewSize , fCrewPeople , Progress1);
RAMPUCScheduleEdit.AjaxSettings.AddAjaxSetting(btnSave2 , btnSave2 , Progress1);
It's basic and effective, but wordy and redundant, right? And a complex page can have a lot more of those lines. So here's an alternative:
SetAjaxUpdates(
new
Control[ , ] {
{fShiftQty, fBalance},
{fShiftQty, fHours},
{fHours , fShiftQty},
{fHours , fBalance} ,
{fCrewSize , fCrewTotal} ,
{fCrewSize , fCrewTemps} ,
{fCrewSize , fCrewPeople },
{btnSave2 , btnSave2}
}
);
And here's the method:
void
SetAjaxUpdates( Control[ , ] controls )
{
for
(
int
i = 0 ; i <= controls.GetUpperBound(0) ; i++ )
RAMPUCScheduleEdit.AjaxSettings.AddAjaxSetting(
controls[ i , 0 ] , controls[ i , 1 ] , Progress1);
}
Assuming that in this case I do want Progress1 to be active for all updates, from a readability perspective do other people here find the alternative preferable to the original? Or am I just adding more code where it's not necessary and abstracting/refactoring into even more complexity?
More importantly, this is what I came up with to try to streamline the code a bit, and make adding new trigger/update relationships easier, but is there a better, or more elegant way to do what I'm doing here?
Opinions? Thanks!