Esempio n. 1
0
        private BaseForumControl CreateDynamicForumControl(SharePointForumControls childControl)
        {
            BaseForumControl control = null;

            try
            {
                string controlTypeName = string.Format("{0}.{1}", ForumConstants.Control_Namespace, childControl.ToString());
                Type   controlType     = Type.GetType(controlTypeName);
                control = Activator.CreateInstance(controlType) as BaseForumControl;
                control.WebPartParent = this;
            }
            catch (ArgumentNullException nullEx)
            {
                AddError(nullEx);
            }

            return(control);
        }
Esempio n. 2
0
        /// <summary>
        /// Notifies server controls that use composition-based implementation to create any child
        /// controls they contain in preparation for posting back or rendering.
        /// This will read in a QueryString called "control" and instantiate a server
        /// control with the same name then add that to the Web Parts controls.
        ///
        /// If no QueryString called "control" is found or invalid, we fall back to the
        /// basic <see cref="ViewForums"/> which just displays the default forum(s).
        /// </summary>
        protected override void CreateChildControls()
        {
            using (Identity.ImpersonateAppPool())
            {
                SharePointForumControls childControl;

                try
                {
                    childControl = (SharePointForumControls)Enum.Parse(typeof(SharePointForumControls), Page.Request.QueryString["control"], true);
                }
                catch
                {
                    childControl = SharePointForumControls.ViewForums;
                }

                BaseForumControl control = CreateDynamicForumControl(childControl);
                if (control != null)
                {
                    Controls.Add(control);
                }
            }
        }