public TUserControl GetUserControl <TUserControl> (string tabViewID) where TUserControl : Control { TabbedMultiView multiView = UserControlMultiView; if (multiView == null) { throw new InvalidOperationException("Page has no UserControlMultiView."); } TabView view = (TabView)multiView.FindControl(tabViewID); if (view == null) { throw new ArgumentOutOfRangeException("No child control with ID " + tabViewID + " found."); } view.EnsureLazyControls(); foreach (Control childControl in view.LazyControls) { if (childControl is TUserControl) { return((TUserControl)childControl); } } throw new ArgumentOutOfRangeException("TabView " + ID + " has no lazy control of type " + typeof(TUserControl).Name + "."); }
protected bool SaveObject() { EnsurePostLoadInvoked(); EnsureValidatableControlsInitialized(); bool isValid = DataSource.Validate(); Control firstInvalidControl = null; foreach (DataEditUserControl control in DataEditUserControls) { if (!control.Validate()) { isValid = false; firstInvalidControl = control; break; } } if (isValid) { foreach (DataEditUserControl control in DataEditUserControls) { control.SaveValues(false); } DataSource.SaveValues(false); _isSaved = true; // transaction will be committed by caller or using auto commit. } else { TabbedMultiView multiView = UserControlMultiView; if (multiView != null) { for (Control control = firstInvalidControl; control != null; control = control.Parent) { if (control is TabView) { multiView.SetActiveView((TabView)control); break; } } } } return(isValid); }