/// <summary>
        /// Creates the control.
        /// </summary>
        /// <param name="view">The view.</param>
        /// <param name="type">The type.</param>
        /// <param name="assembly">The assembly.</param>
        /// <param name="contextName">Name of the context.</param>
        /// <returns>Sitecore.Web.UI.WebControl.</returns>
        public static global::Sitecore.Web.UI.WebControl CreateControl(string view, string contextName)
        {
            var razorView = ViewManager.GetRazorView(view);

            if (razorView == null)
            {
                return(AbstractCachingRenderingType.ErrorControl(view));
            }

            IRazorControl control = new PartialControl();

            control.View        = razorView;
            control.ContextName = contextName;
            return(control as global::Sitecore.Web.UI.WebControl);
        }
Example #2
0
        /// <summary>
        /// Creates the control.
        /// </summary>
        /// <param name="view">The view.</param>
        /// <param name="contextName">Name of the context.</param>
        /// <returns>System.Web.UI.WebControls.WebControl.</returns>
        public static System.Web.UI.WebControls.WebControl CreateControl(string view, string contextName)
        {
            var razorView = ViewManager.GetRazorView(view);

            if (razorView == null)
            {
                return(AbstractCachingRenderingType.ErrorControl(view));
            }

            IRazorControl control = Sitecore.Reflection.ReflectionUtil.CreateObject(typeof(DynamicControl)) as IRazorControl;

            control.View        = razorView;
            control.ContextName = contextName;
            return(control as System.Web.UI.WebControls.WebControl);
        }
        /// <summary>
        /// Creates the control.
        /// </summary>
        /// <param name="view">The view.</param>
        /// <param name="type">The type.</param>
        /// <param name="assembly">The assembly.</param>
        /// <param name="contextName">Name of the context.</param>
        /// <returns>Sitecore.Web.UI.WebControl.</returns>
        public static global::Sitecore.Web.UI.WebControl CreateControl(string view, string type, string assembly, string contextName)
        {
            string typeName = "{0}, {1}".Formatted(type, assembly);

            Type codeBehindType = GetControlType(typeName, _typeLoader);

            var razorView = ViewManager.GetRazorView(view);

            if (razorView == null)
            {
                return(AbstractCachingRenderingType.ErrorControl(view));
            }
            IRazorControl control = global::Sitecore.Reflection.ReflectionUtil.CreateObject(codeBehindType) as IRazorControl;

            control.View        = razorView;
            control.ContextName = contextName;
            return(control as global::Sitecore.Web.UI.WebControl);
        }