public MvcHtmlString TitleUrl(HtmlHelper helper) { switch (ProjectType) { case SourceProjectType.DEPOSIT: return helper.ActionLink(ProjectTitle, "Project", "DataDeposit", new {id = ProjectId}, new {}); default: return helper.ActionLink(ProjectTitle, "Project", "Project", new {id = ProjectId}, new {}); } }
public static MvcHtmlString ProductActionLink(this HtmlHelper htmlHelper, ProductView model) { if (model.Status == ProductStatus.New) { return(htmlHelper.ActionLink("Start progress", "Start", "Product", new { id = model.ID }, null)); } if (model.Status == ProductStatus.InProgress) { return(htmlHelper.ActionLink("Finish progress", "Finish", "Product", new { id = model.ID }, null)); } return(MvcHtmlString.Empty); }
public static MvcHtmlString RawActionLink(this System.Web.Mvc.HtmlHelper htmlHelper, string linkText, string actionName, string controllerName, object routeValues, object htmlAttributes) { var repID = Guid.NewGuid().ToString(); var lnk = htmlHelper.ActionLink(repID, actionName, controllerName, routeValues, htmlAttributes); return(MvcHtmlString.Create(lnk.ToString().Replace(repID, linkText))); }
public static string AddNavigationNode(HtmlHelper htmlHelper, NavigationNode node) { StringBuilder nodeOutput = new StringBuilder(); if (node.Children.Count == 0) { nodeOutput.Append("<li>"); } else { nodeOutput.Append("<li class=\"dropdown\">"); } if (node.Children.Count == 0) { nodeOutput.Append(htmlHelper.ActionLink(node.Name, node.Action, node.Controller).ToString()); } else { nodeOutput.Append(string.Format(@"<a href=""#"" class=""dropdown-toggle"" data-toggle=""dropdown"">{0}<b class=""caret""></b></a>", node.Name)); nodeOutput.Append(AddSubMenu(htmlHelper, node.Children)); } nodeOutput.Append("</li>"); return nodeOutput.ToString(); }
/// <summary> /// Renders the action link containing image. /// </summary> /// <param name="htmlHelper"><c>HtmlHelper</c> instance.</param> /// <param name="src">Image file location.</param> /// <param name="actionName">MVC action name.</param> /// <param name="controllerName">MVC controller name.</param> /// <param name="protocol">HTTP protocal.</param> /// <param name="hostName">Hostname.</param> /// <param name="fragment">URL fragment - anchor name.</param> /// <param name="routeValues">List of the route values.</param> /// <param name="htmlAttributes">List of attributes used for the {a} tag.</param> /// <param name="imageAttributes">List of attributes used for the {img} tag.</param> /// <returns>Returns the action link containing image.</returns> public static MvcHtmlString ImageActionLink(this System.Web.Mvc.HtmlHelper htmlHelper, string src, string actionName, string controllerName, string protocol, string hostName, string fragment, IDictionary <string, object> routeValues, IDictionary <string, object> htmlAttributes, IDictionary <string, object> imageAttributes = null) { if (String.IsNullOrWhiteSpace(src)) { throw new ArgumentNullException("src"); } if (String.IsNullOrWhiteSpace(actionName)) { throw new ArgumentNullException("actionName"); } if (String.IsNullOrWhiteSpace(protocol)) { throw new ArgumentNullException("protocol"); } if (String.IsNullOrWhiteSpace(hostName)) { throw new ArgumentNullException("hostName"); } if (String.IsNullOrWhiteSpace(fragment)) { throw new ArgumentNullException("fragment"); } var actionLink = htmlHelper.ActionLink(".", actionName, controllerName, protocol, hostName, fragment, routeValues, htmlAttributes); var image = htmlHelper.Image(src, imageAttributes); return(new MvcHtmlString(actionLink.ToHtmlString().Replace(">.</a>", ">" + image.ToHtmlString() + "</a>"))); }
public static HtmlString AddActionModalWindow(HtmlHelper helper, string headText, string bodyText, string actionName, string controlName, object paramsList, string applyButtonName, string id) { var a = helper.ActionLink(applyButtonName, actionName, controlName, paramsList, new { @class = "btn btn-default", @id = "CauseLink" }); var result = "<div id='modalWindow" + id + "' class='modal fade' role='dialog'>" + "<div class='modal-dialog'>" + "<div class='modal-content'>" + "<div class='modal-header'>" + "<button type='button' class='close' data-dismiss='modal'>×</button>" + "<h4 class='modal-title'>" + headText + "</h4>" + "</div>" + "<div class='modal-body'>" + "<p>" + bodyText + "</p>" + "</div>" + "<div class='modal-footer'>" + "<button type='button' class='btn btn-default' data-dismiss='modal'>Отмена</button>" + a.ToString() + "</div>" + "</div>" + "</div>" + "</div>"; return new HtmlString(result); }
/// <summary> /// Retorna el texto para un link utlizando el _tag por defecto de la clase. /// </summary> /// <param name="linkText">Texto para el link</param> /// <param name="actionName">Accción para el link</param> /// <param name="ControllerName">Controlador para el link</param> /// <returns></returns> public static MvcHtmlString AuthorizeActionLink ( this System.Web.Mvc.HtmlHelper htmlHelper, MenuAuthorize menuAuthorize, string linkText, string actionName, string ControllerName ) { if (menuAuthorize.HasPermission(actionName, ControllerName)) { return(htmlHelper.ActionLink(linkText, actionName)); //return MvcHtmlString.Create( // string.Format("{0}<a href=\"/{5}/{2}/{3}\">{4}</a>{1}", // menuAuthorize.Tag, // menuAuthorize.TagClose, // ControllerName, // actionName, // linkText, // System.Web.Hosting.HostingEnvironment.ApplicationVirtualPath // )); } return(MvcHtmlString.Create( string.Format("{0}<a class=\"disable\" disabled=\"disabled\">{4}</a>{1}", menuAuthorize.Tag, menuAuthorize.TagClose, ControllerName, actionName, linkText))); }
public static MvcHtmlString CreateProductLink(this HtmlHelper htmlHelper, OrderView model) { if (model.CanCreateProduct) { return(htmlHelper.ActionLink("Create New", "Create", "Product", new { id = model.ID }, null)); } return(MvcHtmlString.Empty); }
public static MvcHtmlString DeliveredLink(this HtmlHelper htmlHelper, OrderView model) { if (model.CanFinishDelivery) { return(htmlHelper.ActionLink("Delivered", "Delivery", "Order", new { id = model.ID }, null)); } return(MvcHtmlString.Empty); }
public static MvcHtmlString PassToRestaurantLink(this HtmlHelper htmlHelper, OrderView model) { if (model.CanPassToRestaurant) { return(htmlHelper.ActionLink("Passed to restaurant", "Restaurant", "Order", new { id = model.ID }, null)); } return(MvcHtmlString.Empty); }
public static MvcHtmlString AuthorizeActionLink(this System.Web.Mvc.HtmlHelper helper, string linkText, string actionName, string controllerName, RouteValueDictionary routeValues, IDictionary <string, object> htmlAttributes) { if (HasActionPermission(helper, actionName, controllerName)) { return(helper.ActionLink(linkText, actionName, controllerName, routeValues, htmlAttributes)); } return(MvcHtmlString.Empty); }
static void AddMenu(HtmlHelper html, string controllerName, string actionName, string linkText, string currentControllerName, StringBuilder output) { if (currentControllerName == controllerName) output.Append("<li class=\"active\">"); else { output.Append("<li>"); } output.Append(html.ActionLink(linkText, actionName, controllerName).ToHtmlString()); output.Append("</li>"); }
public static MvcHtmlString BootstrapActionLinkButton( this System.Web.Mvc.HtmlHelper html, string actionName, object routeValues, ContextualColor contextualColor) { return(html.ActionLink( actionName, actionName, routeValues, new { @class = $"btn btn-{ContextualColors[contextualColor]}" })); }
public void CommentSummaryLinks(dynamic Display, TextWriter Output, HtmlHelper Html, ContentItem item, int count, int pendingCount) { var commentText = ""; if (item.Id != 0) { var totalCommentCount = count + pendingCount; var totalCommentText = T.Plural("1 comment", "{0} comments", totalCommentCount); if (totalCommentCount == 0) { commentText += totalCommentText.ToString(); } else { commentText += Html.ActionLink( totalCommentText.ToString(), "Details", new { Area = "Orchard.Comments", Controller = "Admin", id = item.Id, returnUrl = Html.ViewContext.HttpContext.Request.ToUrlString() }); } if (pendingCount > 0) { commentText += " " + Html.ActionLink(T("({0} pending)", pendingCount).ToString(), "Details", new { Area = "Orchard.Comments", Controller = "Admin", id = item.Id, returnUrl = Html.ViewContext.HttpContext.Request.Url }); } } Output.Write(commentText); }
public void BidsummaryLinks(dynamic display, TextWriter output, HtmlHelper html, ContentItem item, int count, int pendingCount) { var bidText = ""; if (item.Id != 0) { var totalBidCount = count + pendingCount; var totalBidText = T.Plural("1 Bid", "{0} Bids", totalBidCount); if (totalBidCount == 0) { bidText += totalBidText.ToString(); } else { bidText += html.ActionLink( totalBidText.ToString(), "Details", new { Area = "Devq.Bids", Controller = "Admin", id = item.Id, returnUrl = html.ViewContext.HttpContext.Request.ToUrlString() }); } if (pendingCount > 0) { bidText += " " + html.ActionLink(T("({0} pending)", pendingCount).ToString(), "Details", new { Area = "Devq.Bids", Controller = "Admin", id = item.Id, returnUrl = html.ViewContext.HttpContext.Request.Url }); } } output.Write(bidText); }
public static System.Web.Mvc.MvcHtmlString MenuLink(this System.Web.Mvc.HtmlHelper htmlHelper, string linkText, string actionName, string controllerName, string cssClass) { string currentAction = htmlHelper.ViewContext.RouteData.GetRequiredString("action"); string currentController = htmlHelper.ViewContext.RouteData.GetRequiredString("controller"); TagBuilder tb = new TagBuilder("li"); if (string.Equals(currentAction, actionName, StringComparison.OrdinalIgnoreCase) && string.Equals(currentController, controllerName, StringComparison.OrdinalIgnoreCase)) { tb.AddCssClass(cssClass); } // System.Web.Mvc.MvcHtmlString link = htmlHelper.ActionLink(linkText, actionName, controllerName); tb.InnerHtml += htmlHelper.ActionLink(linkText, actionName, controllerName).ToHtmlString(); return(new System.Web.Mvc.MvcHtmlString(tb.ToString())); }
/// <summary> /// Renders the action link containing image. /// </summary> /// <param name="htmlHelper"><c>HtmlHelper</c> instance.</param> /// <param name="src">Image file location.</param> /// <param name="actionName">MVC action name.</param> /// <param name="controllerName">MVC controller name.</param> /// <param name="routeValues">List of the route values.</param> /// <param name="htmlAttributes">List of attributes used for the {a} tag.</param> /// <param name="imageAttributes">List of attributes used for the {img} tag.</param> /// <returns>Returns the action link containing image.</returns> public static MvcHtmlString ImageActionLink(this System.Web.Mvc.HtmlHelper htmlHelper, string src, string actionName, string controllerName, object routeValues, object htmlAttributes, object imageAttributes) { if (String.IsNullOrWhiteSpace(src)) { throw new ArgumentNullException("src"); } if (String.IsNullOrWhiteSpace(actionName)) { throw new ArgumentNullException("actionName"); } var actionLink = htmlHelper.ActionLink(".", actionName, controllerName, routeValues, htmlAttributes); var image = htmlHelper.Image(src, imageAttributes); return(new MvcHtmlString(actionLink.ToHtmlString().Replace(">.</a>", ">" + image.ToHtmlString() + "</a>"))); }
public static MvcHtmlString BootstrapActionLinkButton( this System.Web.Mvc.HtmlHelper html, string actionName, object routeValues, ContextualColor contextualColor, TargetAttribute targetAttribute) { return(html.ActionLink( actionName, actionName, routeValues, new { @class = $"btn btn-{ContextualColors[contextualColor]}", target = Bootstrap.BootstrapExtensions.TargetAttributes[targetAttribute] })); }
public static MvcHtmlString BootstrapActionLinkButton( this System.Web.Mvc.HtmlHelper html, string linkText, string actionName, ContextualColor contextualColor = ContextualColor.Default, TargetAttribute targetAttribute = TargetAttribute.Self) { return(html.ActionLink( linkText, actionName, null, new { @class = $"btn btn-{ContextualColors[contextualColor]}" })); }
public static MvcHtmlString BootstrapActionLinkButton( this System.Web.Mvc.HtmlHelper html, string linkText, string actionName, int id, ContextualColor contextualColor = ContextualColor.Default) { return(html.ActionLink( linkText, actionName, new { id }, new { @class = $"btn btn-{ContextualColors[contextualColor]}" })); }
public static MvcHtmlString BootstrapActionLinkButton( this System.Web.Mvc.HtmlHelper html, string actionName, string controllerName, RouteValueDictionary routeValues, ContextualColor contextualColor) { var htmlAttributes = new Dictionary <string, object> { { "class", $"btn btn-{ContextualColors[contextualColor]}" } }; return(html.ActionLink( actionName, actionName, controllerName, routeValues, htmlAttributes)); }
/// <summary> /// Creates a Bootstrap-styled button for a Html.ActionLink /// with the specified action name, id parameter, and /// contextual class. The action name is used as the link /// text. /// </summary> /// <param name="html">The HTML.</param> /// <param name="actionName">Name of the action.</param> /// <param name="id">The identifier.</param> /// <param name="contextualColor">The contextual class.</param> /// <returns>MvcHtmlString.</returns> /// TODO Edit XML Comment Template for BootstrapActionLinkButton public static MvcHtmlString BootstrapActionLinkButton( this System.Web.Mvc.HtmlHelper html, string actionName, int id, ContextualColor contextualColor = ContextualColor.Default, TargetAttribute targetAttribute = TargetAttribute.Self) { return(html.ActionLink( actionName, actionName, new { id }, new { @class = $"btn btn-{ContextualColors[contextualColor]}", target = Bootstrap.BootstrapExtensions.TargetAttributes[targetAttribute] })); }
public static HtmlString AddActionModalWindowWithTextBox(HtmlHelper helper, string headText, string actionName, string controlName, object paramsList, string applyButtonName, string id, string textBoxName) { var link = helper.ActionLink(applyButtonName, actionName, controlName, paramsList, new {@class = "btn btn-default", @id = "link" + id}); var modalWindow = "<div id='modalWindow" + id + "' class='modal fade' role='dialog'>" + "<div class='modal-dialog'>" + "<div class='modal-content'>" + "<div class='modal-header'>" + "<button type='button' class='close' data-dismiss='modal'>×</button>" + "<h4 class='modal-title'>" + headText + "</h4>" + "</div>" + "<div class='modal-body'>" + "<textarea class='form-control' rows='3' id='" + textBoxName + id +"' style='resize:none'></textarea>" + "</div>" + "<div class='modal-footer'>" + "<button type='button' class='btn btn-default' data-dismiss='modal'>Отмена</button>" + link + "</div>" + "</div>" + "</div>" + "</div>"; var script = "<script type='text/javascript'> $(function() {" + "$('#link" + id + "').click(function () {" + "var name = $('#" + textBoxName + id + "').val();" + "this.href = this.href + '&" + textBoxName + "=' + encodeURIComponent(name);" + "});" + "});" + "</script>"; var result = modalWindow + script; return new HtmlString(result); }
// // 摘要: // 返回包含指定操作的虚拟路径的定位点元素(a 元素)。 // // 参数: // htmlHelper: // 此方法扩展的 HTML 帮助器实例。 // // linkText: // 定位点元素的内部文本。 // // actionName: // 操作的名称。 // // controllerName: // 控制器的名称。 // // 返回结果: // 一个定位点元素(a 元素)。 // // 异常: // System.ArgumentException: // linkText 参数为 null 或为空。 public static MvcHtmlString ActionLinkWithPermission(this HtmlHelper htmlHelper, string linkText, string actionName, string controllerName) { return(htmlHelper.ActionLink(linkText, actionName, controllerName)); }
public static MvcHtmlString ActionLink(this HtmlHelper htmlHelper, string linkText, ActionResult result) { return(htmlHelper.ActionLink(linkText, result, null, null, null, null)); }
// // 摘要: // 返回包含指定操作的虚拟路径的定位点元素(a 元素)。 // // 参数: // htmlHelper: // 此方法扩展的 HTML 帮助器实例。 // // linkText: // 定位点元素的内部文本。 // // actionName: // 操作的名称。 // // controllerName: // 控制器的名称。 // // routeValues: // 一个包含路由参数的对象。通过检查对象的属性,利用反射检索参数。该对象通常是使用对象初始值设定项语法创建的。 // // htmlAttributes: // 一个对象,其中包含要为该元素设置的 HTML 特性。 // // 返回结果: // 一个定位点元素(a 元素)。 // // 异常: // System.ArgumentException: // linkText 参数为 null 或为空。 public static MvcHtmlString ActionLinkWithPermission(this HtmlHelper htmlHelper, string linkText, string actionName, string controllerName, object routeValues, object htmlAttributes) { return(htmlHelper.ActionLink(linkText, actionName, controllerName, routeValues, htmlAttributes)); }
public override MvcHtmlString Link(HtmlHelper htmlHelper) { return htmlHelper.ActionLink(Name, Action, Controller); }
public static IHtmlString ByDateLink(this HtmlHelper html, DateTime viewDate, object htmlAttributes, string dateFormat = "") { var dateDisplay = string.IsNullOrWhiteSpace(dateFormat) ? viewDate.ToDisplayString() : viewDate.ToString(dateFormat); return(html.ActionLink(dateDisplay, "ByDate", "Home", new { @area = string.Empty, dt = viewDate.ToUrlString() }, htmlAttributes)); }
public static MvcHtmlString AccountRegisterLink(HtmlHelper htmlHelper) { return htmlHelper.ActionLink("新しいユーザーとして登録する", AccountController.ActionNames.Register, ControllerNames.Account); }
public static MvcHtmlString ActionLink(this HtmlHelper htmlHelper, string linkText, Task <ActionResult> taskResult, object htmlAttributes, string protocol, string hostName) { return(htmlHelper.ActionLink(linkText, taskResult.Result, htmlAttributes, protocol, hostName, null)); }
public static MvcHtmlString ActionLink(this HtmlHelper htmlHelper, string linkText, ActionResult result, IDictionary <string, object> htmlAttributes, string protocol, string hostName) { return(htmlHelper.ActionLink(linkText, result, htmlAttributes, protocol, hostName, null)); }
public static MvcHtmlString ActionLink(this HtmlHelper htmlHelper, string linkText, ActionResult result, object htmlAttributes, string protocol) { return(htmlHelper.ActionLink(linkText, result, htmlAttributes, protocol, null, null)); }
public static MvcHtmlString ActionLink(this HtmlHelper htmlHelper, string linkText, Task <ActionResult> taskResult, IDictionary <string, object> htmlAttributes, string protocol) { return(htmlHelper.ActionLink(linkText, taskResult.Result, htmlAttributes, protocol, null, null)); }
public static string AddMobileNavigationNode(HtmlHelper htmlHelper, NavigationNode node, string dataTheme, string dataContentTheme) { StringBuilder nodeOutput = new StringBuilder(); if (node.Children.Count > 0) { nodeOutput.Append(string.Format("<div data-role=\"collapsible\" data-theme=\"{0}\" data-content-theme=\"{1}\">", dataTheme, dataContentTheme)); } if (node.Children.Count == 0) { nodeOutput.Append(htmlHelper.ActionLink(node.Name, node.Action, node.Controller, null, new { data_role="button", rel="external" }).ToString()); } else { nodeOutput.Append(AddMobileSubMenu(htmlHelper, node.Children)); } if (node.Children.Count > 0) { nodeOutput.Append("</div>"); } return nodeOutput.ToString(); }
// // 摘要: // 返回包含指定操作的虚拟路径的定位点元素(a 元素)。 // // 参数: // htmlHelper: // 此方法扩展的 HTML 帮助器实例。 // // linkText: // 定位点元素的内部文本。 // // actionName: // 操作的名称。 // // controllerName: // 控制器的名称。 // // protocol: // URL 协议,如“http”或“https”。 // // hostName: // URL 的主机名。 // // fragment: // URL 片段名称(定位点名称)。 // // routeValues: // 一个包含路由参数的对象。 // // htmlAttributes: // 一个对象,其中包含要为该元素设置的 HTML 特性。 // // 返回结果: // 一个定位点元素(a 元素)。 // // 异常: // System.ArgumentException: // linkText 参数为 null 或为空。 public static MvcHtmlString ActionLinkWithPermission(this HtmlHelper htmlHelper, string linkText, string actionName, string controllerName, string protocol, string hostName, string fragment, RouteValueDictionary routeValues, IDictionary <string, object> htmlAttributes) { return(htmlHelper.ActionLink(linkText, actionName, controllerName, protocol, hostName, fragment, routeValues, htmlAttributes)); }
public static MvcHtmlString ActionLink(this HtmlHelper htmlHelper, string linkText, Task <ActionResult> taskResult, object htmlAttributes) { return(htmlHelper.ActionLink(linkText, taskResult.Result, htmlAttributes, null, null, null)); }
/// <summary> /// Returns an anchor element (a element) that contains the virtual path of the specified area action. /// </summary> /// <param name="helper">The HTML helper instance that this method extends.</param> /// <param name="linkText">The inner text of the anchor element.</param> /// <param name="actionName">The name of the action.</param> /// <param name="controllerName">The name of the controller.</param> /// <param name="areaName">The name of the area.</param> /// <param name="htmlAttributes">An object that contains the HTML attributes to set for the element.</param> /// <returns></returns> public static MvcHtmlString ActionLink(this HtmlHelper helper, string linkText, string actionName, string controllerName, string areaName, object htmlAttributes) { return(helper.ActionLink(linkText, actionName, controllerName, new { area = areaName }, htmlAttributes)); }
public override MvcHtmlString EditLink(HtmlHelper htmlHelper) { return htmlHelper.ActionLink<CmsController>(c => c.Edit(ContentId), "Edit"); }
/// <summary> /// Returns an anchor element (a element) that contains the virtual path of the specified area action. /// </summary> /// <param name="helper">The HTML helper instance that this method extends.</param> /// <param name="linkText">The inner text of the anchor element.</param> /// <param name="actionName">The name of the action.</param> /// <param name="controllerName">The name of the controller.</param> /// <param name="areaName">The name of the area.</param> /// <returns></returns> public static MvcHtmlString ActionLink(this HtmlHelper helper, string linkText, string actionName, string controllerName, string areaName) { return(helper.ActionLink(linkText, actionName, controllerName, areaName, null)); }