예제 #1
0
        /// <summary>
        /// Gets the layout template.
        /// </summary>
        /// <param name="templateName">The name of the layout template to render.</param>
        /// <param name="placeholdersOnly">When true the method returns a master page containing only content placeholders.</param>
        /// <returns></returns>
        public virtual string GetLayoutTemplate(string templateName, bool placeholdersOnly = false)
        {
            var genericController = this.CreateController();
            var layoutHtmlString  = this.RenderViewToString(genericController.ControllerContext, templateName, placeholdersOnly);

            if (!layoutHtmlString.IsNullOrEmpty() && !placeholdersOnly)
            {
                var htmlProcessor = new MasterPageBuilder();
                layoutHtmlString = htmlProcessor.ProcessLayoutString(layoutHtmlString);
                layoutHtmlString = htmlProcessor.AddMasterPageDirectives(layoutHtmlString);
            }

            return(layoutHtmlString);
        }
예제 #2
0
        /// <summary>
        /// Gets the layout template.
        /// </summary>
        /// <param name="templateName"></param>
        /// <param name="model">The model.</param>
        /// <param name="isPartial">if set to <c>true</c> requested view is partial.</param>
        /// <returns></returns>
        public virtual string GetLayoutTemplate(string templateName, object model = null, bool isPartial = false)
        {
            var genericController = this.CreateController();
            var layoutHtmlString  = this.RenderViewToString(genericController.ControllerContext, templateName, model, isPartial);

            if (!layoutHtmlString.IsNullOrEmpty())
            {
                var htmlProcessor = new MasterPageBuilder();
                layoutHtmlString = htmlProcessor.ProcessLayoutString(layoutHtmlString);
                layoutHtmlString = htmlProcessor.AddMasterPageDirectives(layoutHtmlString);
            }

            return(layoutHtmlString);
        }
예제 #3
0
        /// <summary>
        /// Gets the layout template.
        /// </summary>
        /// <param name="templateName"></param>
        /// <param name="model">The model.</param>
        /// <param name="partial">if set to <c>true</c> requested view is partial.</param>
        /// <returns></returns>
        public virtual string GetLayoutTemplate(string templateName, object model = null, bool partial = false)
        {
            var genericController = this.CreateController();
            var layoutHtmlString = this.RenderViewToString(genericController.ControllerContext, templateName, model, partial);

            if (!layoutHtmlString.IsNullOrEmpty())
            {
                var htmlProcessor = new MasterPageBuilder();
                layoutHtmlString = htmlProcessor.ProcessLayoutString(layoutHtmlString);
                layoutHtmlString = htmlProcessor.AddMasterPageDirectives(layoutHtmlString);
            }

            return layoutHtmlString;
        }
예제 #4
0
        /// <summary>
        /// Gets the layout template.
        /// </summary>
        /// <param name="templateName">The name of the layout template to render.</param>
        /// <param name="placeholdersOnly">When true the method returns a master page containing only content placeholders.</param>
        /// <returns></returns>
        public virtual string GetLayoutTemplate(string templateName, bool placeholdersOnly = false)
        {
            var genericController = this.CreateController();
            var layoutHtmlString = this.RenderViewToString(genericController.ControllerContext, templateName, placeholdersOnly);

            if (!layoutHtmlString.IsNullOrEmpty() && !placeholdersOnly)
            {
                var htmlProcessor = new MasterPageBuilder();
                layoutHtmlString = htmlProcessor.ProcessLayoutString(layoutHtmlString);
                layoutHtmlString = htmlProcessor.AddMasterPageDirectives(layoutHtmlString);
            }

            return layoutHtmlString;
        }