/// <summary> /// Render an entity (Component Presentation) /// </summary> /// <param name="item">The Component Presentation object</param> /// <param name="helper">The HTML Helper</param> /// <param name="containerSize">The size of the containing element (in grid units)</param> /// <param name="excludedItems">A list of view names, if the Component Presentation maps to one of these, it is skipped.</param> /// <returns>The rendered content</returns> public override MvcHtmlString RenderEntity(object item, HtmlHelper helper, int containerSize = 0, List<string> excludedItems = null) { var cp = item as IComponentPresentation; var mvcData = ContentResolver.ResolveMvcData(cp); if (cp != null && (excludedItems == null || !excludedItems.Contains(mvcData.ViewName))) { var parameters = new RouteValueDictionary(); int parentContainerSize = helper.ViewBag.ContainerSize; if (parentContainerSize == 0) { parentContainerSize = SiteConfiguration.MediaHelper.GridSize; } if (containerSize == 0) { containerSize = SiteConfiguration.MediaHelper.GridSize; } parameters["containerSize"] = (containerSize * parentContainerSize) / SiteConfiguration.MediaHelper.GridSize; parameters["entity"] = cp; parameters["area"] = mvcData.ControllerAreaName; foreach (var key in mvcData.RouteValues.Keys) { parameters[key] = mvcData.RouteValues[key]; } MvcHtmlString result = helper.Action(mvcData.ActionName, mvcData.ControllerName, parameters); if (WebRequestContext.IsPreview) { result = new MvcHtmlString(TridionMarkup.ParseEntity(result.ToString())); } return result; } return null; }
public static string RenderSitecorePlaceHolder(string key) { var sublayoutId = GetSublayoutIdFromPlaceHolder(Sitecore.Context.Item[Sitecore.FieldIDs.LayoutField], key); if (!string.IsNullOrEmpty(sublayoutId)) { var layoutItem = Sitecore.Context.Database.GetItem(ID.Parse(sublayoutId)); var controllerName = layoutItem.Fields["Controller"].Value; var actionName = layoutItem.Fields["Action"].Value; HttpContext.Current.RewritePath(string.Concat("/", controllerName, "/", actionName)); RouteData routeData = RouteTable.Routes.GetRouteData(new HttpContextWrapper(HttpContext.Current)); if (routeData != null) { var factory = new ControllerFactory(); var httpContextBase = new HttpContextWrapper(HttpContext.Current); var context = new RequestContext(httpContextBase, routeData); Type type = factory.GetController(context, controllerName); if (type != null) { var controller = (Controller)factory.GetController(context, type); var controllerContext = new ControllerContext(httpContextBase, routeData, controller); var viewContext = new ViewContext(controllerContext, new FakeView(), controller.ViewData, controller.TempData, TextWriter.Null); var helper = new HtmlHelper(viewContext, new ViewPage()); return helper.Action(actionName, controllerName).ToHtmlString(); } } HttpContext.Current.RewritePath("default.aspx"); } return ""; }
private static string InvokeAction(ControllerBase controller, string actionName, string controllerName, RouteValueDictionary routeValues) { var viewContext = new ViewContext(controller.ControllerContext, new WebFormView(controller.ControllerContext, "tmp"), controller.ViewData, controller.TempData, TextWriter.Null); var htmlHelper = new HtmlHelper(viewContext, new ViewPage()); return htmlHelper.Action(actionName, controllerName, routeValues).ToString(); }
private void RenderAction(IParrotWriter writer, IDictionary<string, object> documentHost, string action, string controllerName, string area, params string[] additional) { RouteValueDictionary routeValues = new RouteValueDictionary(); routeValues["action"] = action; if (!string.IsNullOrWhiteSpace(controllerName)) { routeValues["controller"] = controllerName; } if (!string.IsNullOrWhiteSpace(area)) { routeValues["area"] = area; } var viewContext = documentHost["ViewContext"] as ViewContext; IViewDataContainer container = new ViewPage(); var helper = new HtmlHelper(viewContext, container); writer.Write(helper.Action(action, routeValues).ToHtmlString()); }
private static MvcHtmlString RenderComponentPresentation(IComponentPresentation cp, HtmlHelper htmlHelper) { string controller = _configuration.ComponentPresentationController; string action = _configuration.ComponentPresentationAction; if (cp.ComponentTemplate.MetadataFields != null && cp.ComponentTemplate.MetadataFields.ContainsKey("controller")) { controller = cp.ComponentTemplate.MetadataFields["controller"].Value; } if (cp.ComponentTemplate.MetadataFields != null && cp.ComponentTemplate.MetadataFields.ContainsKey("action")) { action = cp.ComponentTemplate.MetadataFields["action"].Value; } _loggerService.Debug("about to render component presentation with controller {0} and action {1}", LoggingCategory.Performance, controller, action); //return ChildActionExtensions.Action(htmlHelper, action, controller, new { componentPresentation = ((ComponentPresentation)cp) }); MvcHtmlString result = htmlHelper.Action(action, controller, new { componentPresentation = ((ComponentPresentation)cp) }); _loggerService.Debug("finished rendering component presentation with controller {0} and action {1}", LoggingCategory.Performance, controller, action); return result; }
public override MvcHtmlString RenderEdit(HtmlHelper html) { return(html.Action("Edit", "BeelineSettings", new { area = RouteProvider.AreaName })); }
/// <summary> /// Invokes the specified child action method using the specified parameters and returns the result as an HTML string. /// </summary> /// <param name="htmlHelper">The HTML helper instance that this method extends.</param> /// <param name="actionName">The name of the action method to invoke.</param> /// <param name="routeValues">An object that contains the parameters for a route. You can use routeValues to provide the parameters that are bound to the action method parameters. The routeValues parameter is merged with the original route values and overrides them.</param> /// <param name="excludeFromParentCache">A flag that determines whether the action should be excluded from any parent cache.</param> /// <returns>The child action result as an HTML string.</returns> public static MvcHtmlString Action(this HtmlHelper htmlHelper, [AspMvcAction] string actionName, object routeValues, bool excludeFromParentCache) { return(htmlHelper.Action(actionName, null, new RouteValueDictionary(routeValues), excludeFromParentCache)); }
public static MvcHtmlString Widget(this HtmlHelper helper, string widgetZone) { return(helper.Action("WidgetsByZone", "Widget", new { widgetZone = widgetZone })); }
public override MvcHtmlString RenderEdit(HtmlHelper html) { return(html.Action("RenderEdit", "MailSnifferSetting", new { area = RouteProvider.AreaName })); }
public static MvcHtmlString Action(this HtmlHelper helper) { var actionName = helper.ViewContext.RouteData.GetRequiredString("Action"); return(helper.Action(actionName)); }
public static IHtmlString GetPageContent(this HtmlHelper htmlHelper, FrontEndCmsPage model) { string result = string.Empty; PageLanguage backEndCmsPageLanguage = new PagesLanguages().GetPageLanguage(model.PageId, model.LanguageCode); string controllerAction; string[] controllerActionArray; if (model.PageTemplateId.IsNotNull()) { PageTemplate pageTemplate = new PageTemplates().GetPageTemplateById(model.PageTemplateId); IEnumerable <IModuleConnector> moduleConnectors = ModuleConnectorsHelper.GetModuleConnectors(); bool isModuleFound; foreach (string templatePart in ExtensionsHelper.GetHtmlCodeParts(pageTemplate.HtmlCode)) { isModuleFound = false; foreach (IModuleConnector moduleConnector in moduleConnectors) { foreach (SelectListItem module in moduleConnector.GetSelectItemList()) { if (templatePart.ToLower() == module.Value.ToLower()) { isModuleFound = true; controllerAction = templatePart.Substring(2, templatePart.Length - 3); controllerActionArray = controllerAction.Split('-'); result += moduleConnector.GetContent(htmlHelper, model, controllerActionArray[1]); } } } if (!isModuleFound) { if (templatePart == "{$Content}") { if (backEndCmsPageLanguage.IsNotNull()) { //include any extra modules foreach (string pageLanguagePart in ExtensionsHelper.GetHtmlCodeParts(backEndCmsPageLanguage.HtmlCode)) { isModuleFound = false; foreach (IModuleConnector moduleConnector in moduleConnectors) { foreach (SelectListItem module in moduleConnector.GetSelectItemList()) { if (pageLanguagePart.ToLower() == module.Value.ToLower()) { isModuleFound = true; controllerAction = pageLanguagePart.Substring(2, pageLanguagePart.Length - 3); controllerActionArray = controllerAction.Split('-'); result += moduleConnector.GetContent(htmlHelper, model, controllerActionArray[1]); } } } if (!isModuleFound) { if (pageLanguagePart.StartsWith("{$") && pageLanguagePart.EndsWith("}") && pageLanguagePart.Contains('-')) { controllerAction = pageLanguagePart.Substring(2, pageLanguagePart.Length - 3); controllerActionArray = controllerAction.Split('-'); try { result += htmlHelper.Action(controllerActionArray[1], "FrontEnd" + controllerActionArray[0], model).ToString(); } catch (Exception ex) { Elmah.ErrorSignal.FromCurrentContext().Raise(ex); } } else { result += pageLanguagePart; } } } } } else if (templatePart.StartsWith("{$") && templatePart.EndsWith("}") && templatePart.Contains('-')) { controllerAction = templatePart.Substring(2, templatePart.Length - 3); controllerActionArray = controllerAction.Split('-'); result += htmlHelper.Action(controllerActionArray[1], "FrontEnd" + controllerActionArray[0], model).ToString(); } else { result += templatePart; } } } } return(htmlHelper.Raw(result.ReplaceGlobalTokens())); }
public static System.Web.WebPages.HelperResult Block(ExerciseBlock block, BlockRenderContext context, HtmlHelper Html) { return new System.Web.WebPages.HelperResult(__razor_helper_writer => { WebViewPage.WriteLiteralTo(@__razor_helper_writer, "\t<div class=\"exercise\">\r\n"); ExerciseBlockData data = context.GetBlockData(block) ?? new ExerciseBlockData(context.Course.Id, context.Slide as ExerciseSlide) { IsGuest = context.IsGuest, IsLti = context.IsLti }; var manualCheckingId = context.ManualChecking != null ? (int?)context.ManualChecking.Id : null; if (Html != null) { WebViewPage.WriteTo(@__razor_helper_writer, Html.Action("Submission", "Exercise", new { courseId = context.Course.Id, slideId = context.Slide.Id, submissionId = context.VersionId, manualCheckingId = manualCheckingId, isLti = data.IsLti, instructorView = manualCheckingId != null })); } else { WebViewPage.WriteLiteralTo(@__razor_helper_writer, "\t\t\t\t<div class=\"exercise__submission\">\r\n\t\t\t\t\t<textarea class=\"code code-exercise " + "hidden\" data-lang=\""); WebViewPage.WriteTo(@__razor_helper_writer, block.LangId); WebViewPage.WriteLiteralTo(@__razor_helper_writer, "\">"); WebViewPage.WriteTo(@__razor_helper_writer, block.ExerciseInitialCode.EnsureEnoughLines(4)); WebViewPage.WriteLiteralTo(@__razor_helper_writer, "</textarea>\r\n\t\t\t\t\t<div class=\"loading-spinner\">\r\n\t\t\t\t\t\t<img src=\"/Content/loading" + ".gif\" />\r\n\t\t\t\t\t</div>\r\n\t\t\t\t\t"); WebViewPage.WriteTo(@__razor_helper_writer, ExerciseControls(new ExerciseControlsModel(context.Course.Id, (ExerciseSlide)context.Slide) { IsCodeEditableAndSendable = true, DebugView = data.DebugView, RunSolutionUrl = data.RunSolutionUrl, })); WebViewPage.WriteLiteralTo(@__razor_helper_writer, "\r\n\r\n\t\t\t\t\t"); WebViewPage.WriteTo(@__razor_helper_writer, RunErrors()); WebViewPage.WriteLiteralTo(@__razor_helper_writer, "\r\n\t\t\t</div>\r\n"); } WebViewPage.WriteLiteralTo(@__razor_helper_writer, "\t\t\r\n\r\n"); if (data.DebugView) { WebViewPage.WriteLiteralTo(@__razor_helper_writer, "\t\t\t<div>\r\n\t\t\t\t<h3>Подсказки</h3>\r\n\t\t\t\t<ol>\r\n"); foreach (var hint in data.Block.HintsMd) { WebViewPage.WriteLiteralTo(@__razor_helper_writer, "\t\t\t\t\t\t<li>\r\n\t\t\t\t\t\t\t"); WebViewPage.WriteTo(@__razor_helper_writer, MvcHtmlString.Create(hint.RenderMd(context.BaseUrl))); WebViewPage.WriteLiteralTo(@__razor_helper_writer, "\r\n\t\t\t\t\t\t</li>\r\n"); } WebViewPage.WriteLiteralTo(@__razor_helper_writer, "\t\t\t\t</ol>\r\n\t\t\t\t<h3>Комментарий после решения</h3>\r\n\t\t\t\t<p>"); WebViewPage.WriteTo(@__razor_helper_writer, data.Block.CommentAfterExerciseIsSolved); WebViewPage.WriteLiteralTo(@__razor_helper_writer, "</p>\r\n\t\t\t</div>\r\n"); } WebViewPage.WriteLiteralTo(@__razor_helper_writer, "\r\n"); if (context.ManualChecking != null) { var checking = (ManualExerciseChecking)context.ManualChecking; WebViewPage.WriteTo(@__razor_helper_writer, Html.Partial("~/Views/Exercise/_ExerciseScoreForm.cshtml", new ExerciseScoreFormModel(context.Course.Id, (ExerciseSlide) context.Slide, checking, context.GroupId, context.VersionId == null || checking.Submission.Id == context.VersionId))); } WebViewPage.WriteLiteralTo(@__razor_helper_writer, "\t</div>\r\n"); }); }
/// <summary> /// Invokes the specified child action method using the specified parameters and controller name and renders the result inline in the parent view. /// </summary> /// <param name="h">The HTML helper instance that this method extends.</param> /// <param name="actionName">The name of the child action method to invoke.</param> /// <param name="controllerName">The name of the controller that contains the action method.</param> /// <param name="routeValues">A dictionary that contains the parameters for a route. You can use routeValues to provide the parameters that are bound to the action method parameters. The routeValues parameter is merged with the original route values and overrides them.</param> /// <param name="excludeFromParentCache">A flag that determines whether the action should be excluded from any parent cache.</param> public static void RenderAction(this HtmlHelper h, [AspMvcAction] string actionName, [AspMvcController] string controllerName, RouteValueDictionary routeValues, bool excludeFromParentCache) { if (excludeFromParentCache) { var serialisedActionSettings = GetSerialisedActionSettings(actionName, controllerName, routeValues); h.ViewContext.Writer.Write(DonutHoleFiller.DonutMarker, DonutHoleFiller.ActionMarker, serialisedActionSettings, h.Action(actionName, controllerName, routeValues)); } else { h.RenderAction(actionName, controllerName, routeValues); } }
public static MvcHtmlString RenderSourceClass(this HtmlHelper helper, string file, string classname) { return(helper.Action("SourceCode", "SourceCode", new { file, classname })); }
public static HtmlString RenderDocTypeGridEditorItem( this HtmlHelper helper, IPublishedContent content, string editorAlias = "", string viewPath = "", string previewViewPath = "") { if (content == null) { return(new HtmlString(string.Empty)); } var controllerName = content.DocumentTypeAlias + "Surface"; if (!string.IsNullOrWhiteSpace(viewPath)) { viewPath = viewPath.TrimEnd('/') + "/"; } if (!string.IsNullOrWhiteSpace(previewViewPath)) { previewViewPath = previewViewPath.TrimEnd('/') + "/"; } // Try looking for surface controller with action named after the editor alias if (!editorAlias.IsNullOrWhiteSpace() && SurfaceControllerHelper.SurfaceControllerExists(controllerName, editorAlias, true)) { return(helper.Action(editorAlias, controllerName, new { dtgeModel = content, dtgeViewPath = viewPath, dtgePreviewViewPath = previewViewPath })); } // Try looking for surface controller with action named after the doc type alias alias if (SurfaceControllerHelper.SurfaceControllerExists(controllerName, content.DocumentTypeAlias, true)) { return(helper.Action(content.DocumentTypeAlias, controllerName, new { dtgeModel = content, dtgeViewPath = viewPath, dtgePreviewViewPath = previewViewPath })); } // See if a default surface controller has been registered var defaultController = DefaultDocTypeGridEditorSurfaceControllerResolver.Current.GetDefaultControllerType(); if (defaultController != null) { var defaultControllerName = defaultController.Name.Substring(0, defaultController.Name.LastIndexOf("Controller")); // Try looking for an action named after the editor alias if (!editorAlias.IsNullOrWhiteSpace() && SurfaceControllerHelper.SurfaceControllerExists(defaultControllerName, editorAlias, true)) { return(helper.Action(editorAlias, defaultControllerName, new { dtgeModel = content, dtgeViewPath = viewPath, dtgePreviewViewPath = previewViewPath })); } // Try looking for a doc type alias action if (SurfaceControllerHelper.SurfaceControllerExists(defaultControllerName, content.DocumentTypeAlias, true)) { return(helper.Action(content.DocumentTypeAlias, defaultControllerName, new { dtgeModel = content, dtgeViewPath = viewPath, dtgePreviewViewPath = previewViewPath })); } // Just go with a default action name return(helper.Action("Index", defaultControllerName, new { dtgeModel = content, dtgeViewPath = viewPath, dtgePreviewViewPath = previewViewPath })); } // Check for preview view if (!string.IsNullOrWhiteSpace(previewViewPath) && helper.ViewContext.RequestContext.HttpContext.Request.QueryString["dtgePreview"] == "1") { var fullPreviewViewPath = previewViewPath + editorAlias + ".cshtml"; if (ViewEngines.Engines.ViewExists(helper.ViewContext, fullPreviewViewPath, true)) { return(helper.Partial(fullPreviewViewPath, content)); } fullPreviewViewPath = previewViewPath + content.DocumentTypeAlias + ".cshtml"; if (ViewEngines.Engines.ViewExists(helper.ViewContext, fullPreviewViewPath, true)) { return(helper.Partial(fullPreviewViewPath, content)); } fullPreviewViewPath = previewViewPath + "Default.cshtml"; if (ViewEngines.Engines.ViewExists(helper.ViewContext, fullPreviewViewPath, true)) { return(helper.Partial(fullPreviewViewPath, content)); } } // Check for view path view if (!string.IsNullOrWhiteSpace(viewPath)) { var fullViewPath = viewPath + editorAlias + ".cshtml"; if (ViewEngines.Engines.ViewExists(helper.ViewContext, fullViewPath, true)) { return(helper.Partial(fullViewPath, content)); } fullViewPath = viewPath + content.DocumentTypeAlias + ".cshtml"; if (ViewEngines.Engines.ViewExists(helper.ViewContext, fullViewPath, true)) { return(helper.Partial(fullViewPath, content)); } fullViewPath = viewPath + "Default.cshtml"; if (ViewEngines.Engines.ViewExists(helper.ViewContext, fullViewPath, true)) { return(helper.Partial(fullViewPath, content)); } } // Resort to standard partial views if (ViewEngines.Engines.ViewExists(helper.ViewContext, editorAlias, true)) { return(helper.Partial(editorAlias, content)); } return(helper.Partial(content.DocumentTypeAlias, content)); }
public static MvcHtmlString AdminAction(this HtmlHelper htmlHelper, string actionName, string adminControllerName, object htmlAttributes) { return(htmlHelper.Action(actionName, adminControllerName, htmlAttributes)); }
public static MvcHtmlString AdminAction(this HtmlHelper htmlHelper, string actionName, string adminControllerName) { return(htmlHelper.Action(actionName, adminControllerName)); }
public static MvcHtmlString AdminAction(this HtmlHelper htmlHelper, string actionName, object routeValue) { return(htmlHelper.Action(actionName, routeValue)); }
public static MvcHtmlString Basket(this HtmlHelper helper) { return(helper.Action("Index", "Basket", new { area = "basket" })); }
public static MvcHtmlString ModularAction(this HtmlHelper helper, string actionName, string controllerName, RouteValueDictionary arguments) { return(helper.Action(actionName, controllerName, arguments)); }
/// <summary> /// Renders a Tree Picker. /// </summary> /// <param name="html">The HTML.</param> /// <param name="treePickerRenderModel">The tree picker render model.</param> /// <returns></returns> public static IHtmlString TreePicker(this HtmlHelper html, TreePickerRenderModel treePickerRenderModel) { return(html.Action("Index", "TreePicker", new { area = "umbraco", model = treePickerRenderModel })); }
public static MvcHtmlString ModularAction(this HtmlHelper helper, string actionName, string controllerName, string areaName, string moduleName, RouteValueDictionary arguments) { return(helper.Action(actionName, controllerName, AreaHelpers.GetRouteViewDictionary(areaName, moduleName, arguments))); }
/// <summary> /// 文件下载 /// </summary> /// <param name="html">HtmlHelper</param> /// <param name="id">AttachmentItem的ID</param> /// <returns>MvcHtmlString</returns> public static MvcHtmlString FileDownload(this HtmlHelper html, int id) { return(html.Action("FileDownload", "Attachment", new { id = id })); }
/// <summary> /// The render style sheets. /// </summary> /// <param name="htmlHelper">The html helper.</param> /// <typeparam name="T"></typeparam> /// <returns>The <see cref="IHtmlString"/>.</returns> public static IHtmlString RenderStyleSheets <T>(this HtmlHelper htmlHelper) where T : ModuleDescriptor { return(htmlHelper.Action("RenderModuleStyleSheetIncludes", "Rendering", new { moduleDescriptorType = typeof(T) })); }
public static MvcHtmlString Action(this HtmlHelper htmlHelper, ActionMap result) { return(htmlHelper.Action(result.ActionName, result.ControllerName, result.RouteValues)); }
/// <summary> /// Returns the result of a child action of a strongly typed SurfaceController /// </summary> /// <typeparam name="T"></typeparam> /// <param name="htmlHelper"></param> /// <param name="actionName"></param> /// <returns></returns> public static IHtmlString Action <T>(this HtmlHelper htmlHelper, string actionName) where T : SurfaceController { return(htmlHelper.Action(actionName, typeof(T))); }
/// <summary> /// Renders a dashboard item /// </summary> /// <param name="html"></param> /// <param name="model"></param> /// <returns></returns> public static IHtmlString RenderDashboard(this HtmlHelper html, DashboardItemModel model) { return(html.Action("RenderDashboard", "DashboardEditor", new { model })); }
public static HtmlString RenderDocTypeGridEditorItem( this HtmlHelper helper, IPublishedContent content, string editorAlias = "", string viewPath = "", string previewViewPath = "", bool isPreview = false) { if (content == null) { return(new HtmlString(string.Empty)); } var controllerName = $"{content.DocumentTypeAlias}Surface"; if (string.IsNullOrWhiteSpace(viewPath) == false) { viewPath = viewPath.EnsureEndsWith('/'); } if (string.IsNullOrWhiteSpace(previewViewPath) == false) { previewViewPath = previewViewPath.EnsureEndsWith('/'); } var routeValues = new { dtgeModel = content, dtgeViewPath = viewPath, dtgePreviewViewPath = previewViewPath, dtgePreview = isPreview }; // Try looking for surface controller with action named after the editor alias if (string.IsNullOrWhiteSpace(editorAlias) == false && SurfaceControllerHelper.SurfaceControllerExists(controllerName, editorAlias, true)) { return(helper.Action(editorAlias, controllerName, routeValues)); } // Try looking for surface controller with action named after the doc type alias alias if (SurfaceControllerHelper.SurfaceControllerExists(controllerName, content.DocumentTypeAlias, true)) { return(helper.Action(content.DocumentTypeAlias, controllerName, routeValues)); } // See if a default surface controller has been registered var defaultController = DefaultDocTypeGridEditorSurfaceControllerResolver.Current.GetDefaultControllerType(); if (defaultController != null) { var defaultControllerName = defaultController.Name.Substring(0, defaultController.Name.LastIndexOf("Controller")); // Try looking for an action named after the editor alias if (string.IsNullOrWhiteSpace(editorAlias) == false && SurfaceControllerHelper.SurfaceControllerExists(defaultControllerName, editorAlias, true)) { return(helper.Action(editorAlias, defaultControllerName, routeValues)); } // Try looking for a doc type alias action if (SurfaceControllerHelper.SurfaceControllerExists(defaultControllerName, content.DocumentTypeAlias, true)) { return(helper.Action(content.DocumentTypeAlias, defaultControllerName, routeValues)); } // Just go with a default action name return(helper.Action("Index", defaultControllerName, routeValues)); } // Check for preview view if (string.IsNullOrWhiteSpace(previewViewPath) == false && isPreview) { var fullPreviewViewPath = $"{previewViewPath}{editorAlias}.cshtml"; if (ViewHelper.ViewExists(helper.ViewContext, fullPreviewViewPath, true)) { return(helper.Partial(fullPreviewViewPath, content)); } fullPreviewViewPath = $"{previewViewPath}{content.DocumentTypeAlias}.cshtml"; if (ViewHelper.ViewExists(helper.ViewContext, fullPreviewViewPath, true)) { return(helper.Partial(fullPreviewViewPath, content)); } fullPreviewViewPath = $"{previewViewPath}Default.cshtml"; if (ViewHelper.ViewExists(helper.ViewContext, fullPreviewViewPath, true)) { return(helper.Partial(fullPreviewViewPath, content)); } } // Check for view path view if (string.IsNullOrWhiteSpace(viewPath) == false) { var fullViewPath = $"{viewPath}{editorAlias}.cshtml"; if (ViewHelper.ViewExists(helper.ViewContext, fullViewPath, true)) { return(helper.Partial(fullViewPath, content)); } fullViewPath = $"{viewPath}{content.DocumentTypeAlias}.cshtml"; if (ViewHelper.ViewExists(helper.ViewContext, fullViewPath, true)) { return(helper.Partial(fullViewPath, content)); } fullViewPath = $"{viewPath}Default.cshtml"; if (ViewHelper.ViewExists(helper.ViewContext, fullViewPath, true)) { return(helper.Partial(fullViewPath, content)); } } // Resort to standard partial views if (ViewHelper.ViewExists(helper.ViewContext, editorAlias, true)) { return(helper.Partial(editorAlias, content)); } return(helper.Partial(content.DocumentTypeAlias, content)); }
public static MvcHtmlString Griddly(this HtmlHelper htmlHelper, string actionName, string controllerName, object routeValues) { // TODO: validate that we got a GriddlyResult return(htmlHelper.Action(actionName, controllerName, routeValues)); }
public static MvcHtmlString SecureAction(this HtmlHelper htmlHelper, ActionResult result) { var callInfo = result.GetT4MVCResult(); return(htmlHelper.Action(callInfo.Action, callInfo.Controller, callInfo.RouteValueDictionary)); }
public static MvcHtmlString Widget(this HtmlHelper helper, string widgetZone, object additionalData = null) { return(helper.Action("WidgetsByZone", "Widget", new { widgetZone = widgetZone, additionalData = additionalData })); }
// // GET: /BeelineSettingsModule/ public override MvcHtmlString RenderDisplay(HtmlHelper html) { return(html.Action("View", "Home", new { area = RouteProvider.AreaName })); }
/// <summary> /// Invokes the specified child action method and returns the result as an HTML string. /// </summary> /// <param name="htmlHelper">The HTML helper instance that this method extends.</param> /// <param name="actionName">The name of the action method to invoke.</param> /// <param name="excludeFromParentCache">A flag that determines whether the action should be excluded from any parent cache.</param> /// <returns>The child action result as an HTML string.</returns> public static MvcHtmlString Action(this HtmlHelper htmlHelper, [AspMvcAction] string actionName, bool excludeFromParentCache) { return(htmlHelper.Action(actionName, null, null, excludeFromParentCache)); }
/// <summary> /// Invokes the specified child action method using the specified parameters and returns the result as an HTML string. /// </summary> /// <param name="h">The HTML helper instance that this method extends.</param> /// <param name="actionName">The name of the action method to invoke.</param> /// <param name="routeValues">A dictionary that contains the parameters for a route. You can use routeValues to provide the parameters that are bound to the action method parameters. The routeValues parameter is merged with the original route values and overrides them.</param> /// <param name="excludeFromParentCache">A flag that determines whether the action should be excluded from any parent cache.</param> /// <returns>The child action result as an HTML string.</returns> public static MvcHtmlString Action(this HtmlHelper h, [AspMvcAction] string actionName, RouteValueDictionary routeValues, bool excludeFromParentCache) { return(h.Action(actionName, null, routeValues, excludeFromParentCache)); }
private static MvcHtmlString RenderComponentPresentation(IComponentPresentation cp, HtmlHelper htmlHelper) { string controller = _configuration.ComponentPresentationController; if (cp.ComponentTemplate.MetadataFields != null && cp.ComponentTemplate.MetadataFields.ContainsKey("controller")) { controller = cp.ComponentTemplate.MetadataFields["controller"].Value; } if (string.IsNullOrEmpty(controller)) { throw new InvalidOperationException("Controller was not configured in component template metadata or in application settings. " + "Unable to Render component presentation."); } string action = _configuration.ComponentPresentationAction; if (cp.ComponentTemplate.MetadataFields != null && cp.ComponentTemplate.MetadataFields.ContainsKey("action")) { action = cp.ComponentTemplate.MetadataFields["action"].Value; } if (string.IsNullOrEmpty(action)) { throw new InvalidOperationException("Action was not configured in component template metadata or in application settings. " + "Unable to Render component presentation."); } _loggerService.Debug("about to render component presentation with controller {0} and action {1}", LoggingCategory.Performance, controller, action); //return ChildActionExtensions.Action(htmlHelper, action, controller, new { componentPresentation = ((ComponentPresentation)cp) }); MvcHtmlString result = htmlHelper.Action(action, controller, new { componentPresentation = ((ComponentPresentation)cp) }); _loggerService.Debug("finished rendering component presentation with controller {0} and action {1}", LoggingCategory.Performance, controller, action); return result; }
/// <summary> /// Render an Region /// </summary> /// <param name="item">The Region object</param> /// <param name="helper">The HTML Helper</param> /// <param name="containerSize">The size of the containing element (in grid units)</param> /// <param name="excludedItems">A list of view names, if the Region maps to one of these, it is skipped.</param> /// <returns>The rendered content</returns> public override MvcHtmlString RenderRegion(IRegion region, HtmlHelper helper, int containerSize = 0, List<string> excludedItems = null) { var mvcData = ContentResolver.ResolveMvcData(region); if (region != null && (excludedItems == null || !excludedItems.Contains(region.Name))) { if (containerSize == 0) { containerSize = SiteConfiguration.MediaHelper.GridSize; } MvcHtmlString result = helper.Action(mvcData.ActionName, mvcData.ControllerName, new { Region = region, containerSize = containerSize, area = mvcData.ControllerAreaName }); if (WebRequestContext.IsPreview) { result = new MvcHtmlString(TridionMarkup.ParseRegion(result.ToString())); } return result; } return null; }
/// <summary> /// Invokes the specified child action method using the specified parameters and controller name and returns the result as an HTML string. /// </summary> /// <param name="h">The HTML helper instance that this method extends.</param> /// <param name="actionName">The name of the action method to invoke.</param> /// <param name="controllerName">The name of the controller that contains the action method.</param> /// <param name="excludeFromParentCache">A flag that determines whether the action should be excluded from any parent cache.</param> /// <returns>The child action result as an HTML string.</returns> public static MvcHtmlString Action(this HtmlHelper h, [AspMvcAction] string actionName, [AspMvcController] string controllerName, bool excludeFromParentCache) { return(h.Action(actionName, controllerName, null, excludeFromParentCache)); }
private static MvcHtmlString GetCommentsList(HtmlHelper helper, IDataItem item, string title) { if (SystemManager.GetModule("Comments") == null || item == null) { return MvcHtmlString.Empty; } var itemTypeFullName = item.GetType().FullName; var itemProviderName = item.GetProviderName(); var itemThreadKey = ControlUtilities.GetLocalizedKey(item.Id, null, CommentsBehaviorUtilities.GetLocalizedKeySuffix(itemTypeFullName)); var itemGroupKey = ControlUtilities.GetUniqueProviderKey(GetDataSourceName(item), itemProviderName); var routeDictionary = new System.Web.Routing.RouteValueDictionary() { { "AllowComments", GetAllowComments(item) }, { "ThreadKey", itemThreadKey }, { "ThreadTitle", title }, { "ThreadType", itemTypeFullName }, { "GroupKey", itemGroupKey }, { "DataSource", itemProviderName } }; var controllerName = itemThreadKey.EndsWith(ReviewsSuffix, StringComparison.Ordinal) ? CommentsHelpers.ReviewsControllerName : CommentsHelpers.CommentsControllerName; MvcHtmlString result; try { result = helper.Action(CommentsHelpers.IndexActionName, controllerName, routeDictionary); } catch (HttpException) { result = MvcHtmlString.Empty; } catch (NullReferenceException) { //// Telerik.Sitefinity.Mvc.SitefinityMvcRoute GetOrderedParameters() on line 116 controllerType.GetMethods() throws null reference exception (controllerType is null). result = MvcHtmlString.Empty; } return result; }
public static MvcHtmlString Render(this HtmlHelper htmlHelper, IRenderableViewModel viewModel) { return(htmlHelper.Action(viewModel.RenderData.Action, viewModel.RenderData.Controller, new { model = viewModel, view = viewModel.RenderData.View })); }
public void RenderTemplate(ContentItem item, HtmlHelper helper, TextWriter writer = null) { RouteValueDictionary values = GetRouteValues(helper, item); if (values == null) return; var currentPath = helper.ViewContext.RouteData.CurrentPath(); try { var newPath = currentPath.Clone(currentPath.CurrentPage, item); helper.ViewContext.RouteData.ApplyCurrentPath(newPath); if (writer == null) helper.RenderAction("Index", values); else writer.Write(helper.Action("Index", values)); } finally { helper.ViewContext.RouteData.ApplyCurrentPath(currentPath); } }