RegisterErrorControl() private method

private RegisterErrorControl ( ErrorControl errorControl ) : void
errorControl SenseNet.Portal.UI.Controls.ErrorControl
return void
Example #1
0
        internal static ContentView RegisterControl(ViewControlBase control)
        {
            //-- #1: cast
            ErrorControl errorControl = null;
            FieldControl fieldControl = control as FieldControl;

            if (fieldControl == null)
            {
                errorControl = control as ErrorControl;
            }

            //-- #2: get ContentView
            Control parent = control.Parent;

            while (parent != null && !(parent is ContentView))
            {
                parent = parent.Parent;
            }
            ContentView view = (parent as ContentView);

            //-- #3: there is not a ContentView in the parent axis: exception
            if (view == null)
            {
                if (fieldControl != null)
                {
                    throw new ApplicationException(String.Concat("Control did not find the ContentView. Control type: ", control.GetType().FullName, ", Id: '", control.ID, "', FieldName: '", fieldControl.FieldName, "'"));
                }
                throw new ApplicationException(String.Concat("Control did not find the ContentView. Control type: ", control.GetType().FullName, ", Id: '", control.ID));
            }

            //-- #4 finish if GenericFieldControl or others
            if (fieldControl == null && errorControl == null)
            {
                return(view);
            }

            //-- #5 register by type
            if (errorControl != null)
            {
                view.RegisterErrorControl(errorControl);
            }
            else
            {
                view.RegisterFieldControl(fieldControl);
            }

            //-- #6 introduce the view to caller
            return(view);
        }