public void ActionLinkWithNullActionNameAndNullOptions() { // Arrange AjaxHelper ajaxHelper = GetAjaxHelper(); // Act MvcHtmlString actionLink = ajaxHelper.ActionLink("linkText", null, null); // Assert Assert.AreEqual(@"<a href=""" + MvcHelper.AppPathModifier + @"/app/home/oldaction"" onclick=""Sys.Mvc.AsyncHyperlink.handleClick(this, new Sys.UI.DomEvent(event), { insertionMode: Sys.Mvc.InsertionMode.replace });"">linkText</a>", actionLink.ToHtmlString()); }
/// <summary> /// /// </summary> /// <param name="helper"></param> /// <param name="imageUrl">Image URL</param> /// <param name="actionName">Action Name</param> /// <param name="routeValues">Route Values</param> /// <param name="ajaxOptions">Ajax Options</param> /// <param name="htmlAttribute">HTML Attributes</param> /// <returns></returns> public static MvcHtmlString ImageActionLink(this AjaxHelper helper, string imageUrl, string actionName, string controllerName, object routeValues, AjaxOptions ajaxOptions, object htmlAttribute) { var builder = new TagBuilder("img"); builder.MergeAttribute("src", imageUrl); builder.MergeAttribute("alt", ""); var link = helper.ActionLink("[replaceme]", actionName, controllerName, routeValues, ajaxOptions, htmlAttribute); var html = link.ToHtmlString().Replace("[replaceme]", builder.ToString(TagRenderMode.SelfClosing)); return(new MvcHtmlString(html)); }
public static MvcHtmlString IconActionLink(this AjaxHelper helper, string icon, string text, string actionName, string controllerName, object routeValues, AjaxOptions ajaxOptions, object htmlAttributes) { var linkText = String.IsNullOrWhiteSpace(text) ? "" : " " + text; var builder = new TagBuilder("i"); builder.MergeAttribute("class", icon); var link = helper.ActionLink("[replaceme]" + linkText, actionName, controllerName, routeValues, ajaxOptions, htmlAttributes).ToHtmlString(); return(new MvcHtmlString(link.Replace("[replaceme]", builder.ToString()))); }
public static MvcHtmlString ImageActionLink(this AjaxHelper helper, string imageUrl, string titleText, string actionName, string controller, object routeValues , AjaxOptions ajaxOptions, object htmlAttributes) { var imgTag = new TagBuilder("img"); imgTag.MergeAttribute("src", imageUrl); imgTag.MergeAttribute("title", titleText); var link = helper.ActionLink("[replaceme] " + titleText, actionName, controller, routeValues, ajaxOptions, htmlAttributes).ToHtmlString(); //update return(new MvcHtmlString(link.Replace("[replaceme]", imgTag.ToString(TagRenderMode.SelfClosing)))); }
/// <summary> /// 最全的重载 /// </summary> /// <param name="ajaxHelper"></param> /// <param name="linkText"></param> /// <param name="actionName"></param> /// <param name="controllerName"></param> /// <param name="ajaxOptions"></param> /// <param name="htmlAttributes"></param> /// <returns></returns> public static MvcHtmlString InkindActionLink(this AjaxHelper ajaxHelper, string username, string linkText, string actionName, string controllerName, object routeValues, AjaxOptions ajaxOptions, object htmlAttributes) { if (!CheckPower(actionName, controllerName)) { return(new MvcHtmlString("")); } string htmlString = ajaxHelper.ActionLink(linkText.ToEString().Trim(), actionName, controllerName, routeValues, ajaxOptions, htmlAttributes).ToHtmlString().ToString(); return(new MvcHtmlString(htmlString)); }
public static MvcHtmlString ActionLinkCloseSidebar(this AjaxHelper ajaxHelper, string linkText, string actionName, string controllerName, object routeValues = null, object htmlAttributes = null) { AjaxOptions ajaxOptions = new AjaxOptions { HttpMethod = "GET", OnBegin = "closeSidebar", OnSuccess = "onGetRequestSuccess" }; return(ajaxHelper.ActionLink(linkText, actionName, controllerName, routeValues, ajaxOptions, htmlAttributes)); }
public static IHtmlString ImageActionLink(this AjaxHelper helper, string imageUrl, string altText, string actionName, string controllerName, object routeValues, AjaxOptions ajaxOptions, object htmlAttributes, string imgCssClasses) { var builder = new TagBuilder("img"); builder.MergeAttribute("src", imageUrl); builder.MergeAttribute("alt", altText); builder.AddCssClass(imgCssClasses); var link = helper.ActionLink("[replaceme]", actionName, controllerName, routeValues, ajaxOptions, htmlAttributes); return(MvcHtmlString.Create(link.ToHtmlString().Replace("[replaceme]", builder.ToString(TagRenderMode.SelfClosing)))); }
public static IHtmlString ImageActionLink(this AjaxHelper helper, string imageUrl, string altText, string actionName, object routeValues, AjaxOptions ajaxOptions, object htmlAttributes = null) { var builder = new TagBuilder("img"); builder.MergeAttribute("src", imageUrl); builder.MergeAttribute("alt", altText); builder.MergeAttributes(new RouteValueDictionary(htmlAttributes)); var link = helper.ActionLink("[replaceme]", actionName, routeValues, ajaxOptions).ToHtmlString(); return(MvcHtmlString.Create(link.Replace("[replaceme]", builder.ToString(TagRenderMode.SelfClosing)))); }
public static MvcHtmlString RawActionLink(this AjaxHelper ajaxHelper, string rawHtml, string action, string controller, object routeValues, AjaxOptions ajaxOptions, object htmlAttributes) { //string anchor = ajaxHelper.ActionLink("##holder##", action, controller, routeValues, ajaxOptions, htmlAttributes).ToString(); //return MvcHtmlString.Create(anchor.Replace("##holder##", rawHtml)); /* Updated code to use a generated guid as from the suggestion of Phillip Haydon */ string holder = Guid.NewGuid().ToString(); string anchor = ajaxHelper.ActionLink(holder, action, controller, routeValues, ajaxOptions, htmlAttributes).ToString(); return(MvcHtmlString.Create(anchor.Replace(holder, rawHtml))); }
public void ActionLink() { // Arrange AjaxHelper ajaxHelper = GetAjaxHelper(); // Act string actionLink = ajaxHelper.ActionLink("linkText", "Action", GetEmptyOptions()); // Assert Assert.AreEqual(@"<a href=""" + HtmlHelperTest.AppPathModifier + @"/app/home/Action"" onclick=""Sys.Mvc.AsyncHyperlink.handleClick(this, new Sys.UI.DomEvent(event), { insertionMode: Sys.Mvc.InsertionMode.replace });"">linkText</a>", actionLink); }
public static MvcHtmlString PageLinks(this HtmlHelper html, PageInfo pageInfo, string actionName, Func <int, object> pageParam, AjaxHelper ajaxHelper, AjaxOptions ajaxOptions) { StringBuilder result = new StringBuilder(); for (int i = 1; i <= pageInfo.TotalPages; i++) { if (i == pageInfo.PageNumber) { result.Append(ajaxHelper.ActionLink(i.ToString(), actionName, pageParam(i), ajaxOptions, new { @class = "btn btn-primary" })); } else { result.Append(ajaxHelper.ActionLink(i.ToString(), actionName, pageParam(i), ajaxOptions, new { @class = "btn btn-default" })); } } return(MvcHtmlString.Create(result.ToString())); }
private static IHtmlString IconActionLinkBase(this AjaxHelper helper, string iconClass, string linkText, string actionName, string controlerName, object routeValues, AjaxOptions ajaxOptions, object linkHtmlAttribute) { string link = ""; controlerName = controlerName == "" ? null : controlerName; link = helper.ActionLink("[replaceme]", actionName, controlerName, routeValues, ajaxOptions).ToHtmlString(); if (controlerName == null) { link = helper.ActionLink("[replaceme]", actionName, routeValues, ajaxOptions, linkHtmlAttribute).ToHtmlString(); } else { link = helper.ActionLink("[replaceme]", actionName, controlerName, routeValues, ajaxOptions, linkHtmlAttribute).ToHtmlString(); } var iconHtml = IconBuilder(iconClass) + linkText; return(MvcHtmlString.Create(link.Replace("[replaceme]", iconHtml))); }
private static IHtmlString ImageActionLinkBase(this AjaxHelper helper, string imageUrl, string altText, string actionName, string controlerName, object routeValues, AjaxOptions ajaxOptions, object imageHtmlAttribute, object linkHtmlAttribute) { string link = ""; controlerName = controlerName == "" ? null : controlerName; link = helper.ActionLink("[replaceme]", actionName, controlerName, routeValues, ajaxOptions).ToHtmlString(); if (controlerName == null) { link = helper.ActionLink("[replaceme]", actionName, routeValues, ajaxOptions, linkHtmlAttribute).ToHtmlString(); } else { link = helper.ActionLink("[replaceme]", actionName, controlerName, routeValues, ajaxOptions, linkHtmlAttribute).ToHtmlString(); } var imgHtml = ImageBuilder(imageUrl, altText, imageHtmlAttribute); return(MvcHtmlString.Create(link.Replace("[replaceme]", imgHtml))); }
public static IHtmlString AddActionLink(this AjaxHelper helper, string value, string actionName, object routeValue, AjaxOptions ajaxOptions, object htmlAttributes) { var builder = new TagBuilder("i"); builder.AddCssClass("fa fa-plus-circle"); var link = helper.ActionLink("[replaceme]", actionName, routeValue, ajaxOptions, htmlAttributes).ToHtmlString(); return(new MvcHtmlString(link.Replace("[replaceme]", builder + value))); }
public void ActionLinkWithNullOrEmptyLinkTextThrows() { // Arrange AjaxHelper ajaxHelper = GetAjaxHelper(); // Act & Assert ExceptionHelper.ExpectArgumentExceptionNullOrEmpty( delegate { string actionLink = ajaxHelper.ActionLink(String.Empty, String.Empty, null, null, null, null); }, "linkText"); }
public static MvcHtmlString RawActionLinkWithoutIcon(this AjaxHelper ajaxHelper, string linkText, string icon, string actionName, string controllerName, object routeValues, AjaxOptions ajaxOptions, object htmlAttributes, bool clearPage = false) { var repID = Guid.NewGuid().ToString(); InitAjaxOptions(icon, actionName, controllerName, ajaxOptions, clearPage); var lnk = ajaxHelper.ActionLink(repID, actionName, controllerName, routeValues, ajaxOptions, htmlAttributes); return(MvcHtmlString.Create(lnk.ToString().Replace(repID, linkText))); // return $" <a href='{destination}'></a>"; }
/// <summary> /// Diese Extension-Methode erzeugt einen Ajax Actionlink mit Font Awesome Icons. /// </summary> /// <param name="ajaxHelper">AjaxHelper</param> /// <param name="linkText">Der Linktext des Actionlinks, mit möglichen HTML Elementen</param> /// <param name="actionName">Actioname des Controllers</param> /// <param name="controllerName">Controllername</param> /// <param name="routeValues">RouteValues</param> /// <param name="ajaxOptions">AjaxOptions</param> /// <param name="htmlAttributes">htmlAttributes</param> /// <param name="faClass">Die CSS Klasse des FA Icons</param> /// <param name="left">Falls true, wird das Icon linksbündig vom Text dargestellt</param> /// <returns>Ajax.Actionlink</returns> public static MvcHtmlString ActionLinkWithIcon(this AjaxHelper ajaxHelper, string linkText, string faClass, bool left, string actionName, string controllerName, object routeValues, AjaxOptions ajaxOptions, object htmlAttributes) { var repId = Guid.NewGuid().ToString(); var lnk = ajaxHelper.ActionLink(repId, actionName, controllerName, routeValues, ajaxOptions, htmlAttributes); var newLinkText = left ? ("<i class=\"" + faClass + "\" ></i> " + linkText) : (linkText + " <i class=\"" + faClass + "\" ></i>"); return(MvcHtmlString.Create(lnk.ToString().Replace(repId, newLinkText))); }
// <a ...> // <i class="iconCssClass"></i> // <span class="spanHeaderCssClass">linkText</span> // <span class="spanControlCssClass"> // <i class="iconControlCssClass"></i> // </span> // </a> public static MvcHtmlString ActionLinkTree(this AjaxHelper ajaxHelper, string linkText, string actionName, string controllerName, object routeValues, AjaxOptions ajaxOptions, string iconCssClass, string iconControlCssClass, string spanHeaderCssClass = null, string spanControlCssClass = null) { CheckNotNull(linkText, actionName, controllerName, iconCssClass, iconControlCssClass); var tagsString = TagBuilderHelper.Tree(linkText, iconCssClass, iconControlCssClass, spanHeaderCssClass, spanControlCssClass); var actionLink = ajaxHelper.ActionLink(linkText: @"[replacetext]", actionName: actionName, controllerName: controllerName, routeValues: routeValues, ajaxOptions: ajaxOptions).ToHtmlString(); return(new MvcHtmlString(actionLink.Replace(@"[replacetext]", tagsString))); }
public static MvcHtmlString ActionImageLink(this AjaxHelper helper, string imageUrl, string imageClass, string imageId, string onclick, string actionName, string controller, object routeValues, AjaxOptions ajaxOptions) { var builder = new TagBuilder("img"); builder.MergeAttribute("src", imageUrl); builder.MergeAttribute("class", imageClass); builder.MergeAttribute("id", imageId); builder.MergeAttribute("onclick", onclick); var link = helper.ActionLink("[replaceme]", actionName, controller, routeValues, ajaxOptions); return(new MvcHtmlString(link.ToHtmlString().Replace("[replaceme]", builder.ToString(TagRenderMode.SelfClosing)))); }
// <a ...> // <i class="iconCssClass"></i> // </a> public static MvcHtmlString ActionLinkIcon(this AjaxHelper ajaxHelper, string actionName, string controllerName, AjaxOptions ajaxOptions, string iconCssClass, object routeValues = null, object htmlAttributes = null) { CheckNotNull(actionName, controllerName, iconCssClass); var tagString = TagBuilderHelper.Icon(iconCssClass); var actionLink = ajaxHelper.ActionLink(linkText: @"[replacetext]", actionName: actionName, controllerName: controllerName, ajaxOptions: ajaxOptions, routeValues: routeValues, htmlAttributes: htmlAttributes).ToHtmlString(); return(new MvcHtmlString(actionLink.Replace(@"[replacetext]", tagString))); }
private static string EnabledButton(AjaxHelper helper, int nextPageNumber, string textButton) { _hasMorePages = true; var routeValues = _dataObject.RouteValues.BuildRouteObject(nextPageNumber); return(helper.ActionLink(textButton, _dataObject.ActionName, _dataObject.ControllerName, routeValues, _dataObject.AjaxOptions, _dataObject.HtmlAttrebutes).ToString()); }
public static string ImageActionLink(this AjaxHelper helper, string imageUrl, string altText, string titleText, string actionName, object routeValues, AjaxOptions ajaxOptions) { var builder = new TagBuilder("img"); builder.MergeAttribute("src", imageUrl); builder.MergeAttribute("alt", altText); builder.MergeAttribute("title", titleText); var link = helper.ActionLink("[replaceme]", actionName, routeValues, ajaxOptions); return(link.ToString().Replace("[replaceme]", builder.ToString(TagRenderMode.SelfClosing))); }
private static MvcHtmlString ComposeImageActionLink(AjaxHelper helper, string imageUrl, string altText, string actionName, string controllerName, object routeValues, AjaxOptions ajaxOptions, object htmlAttributes = null) { var builder = new TagBuilder("img"); builder.MergeAttribute("src", imageUrl); builder.MergeAttribute("alt", altText); string link = helper.ActionLink("[replaceme]", actionName, controllerName, routeValues, ajaxOptions, htmlAttributes).ToHtmlString(); return(new MvcHtmlString(link.Replace("[replaceme]", builder.ToString(TagRenderMode.SelfClosing)))); }
public static IHtmlString ImageActionLink(this AjaxHelper helper, string imageUrl, string championName, int championId, string actionName, object routeValues, AjaxOptions ajaxOptions, object htmlAttributes = null) { var sb = new StringBuilder(); sb.AppendLine("<figure class='championItem' id='champion" + championId.ToString() + "'>"); sb.AppendLine("<img src='" + imageUrl + "' alt='" + championName + "' />"); sb.AppendLine("<figcaption>" + championName + "</figcaption>"); sb.AppendLine("</figure>"); var link = helper.ActionLink("[replaceme]", actionName, routeValues, ajaxOptions).ToHtmlString(); return(MvcHtmlString.Create(link.Replace("[replaceme]", sb.ToString()))); }
/// <summary> /// /// </summary> /// <param name="ajaxHelper"></param> /// <param name="linktext"></param> /// <param name="actionName"></param> /// <param name="controllerName"></param> /// <param name="routevalues"></param> /// <param name="ajaxOptions"></param> /// <param name="htmlAttributes"></param> /// <returns></returns> public static MvcHtmlString RawActionLink(this AjaxHelper ajaxHelper, string linktext, string actionName, string controllerName, object routevalues, AjaxOptions ajaxOptions, object htmlAttributes) { var repID = Guid.NewGuid().ToString(); var lnk = ajaxHelper.ActionLink(repID, actionName, controllerName, routevalues, ajaxOptions, htmlAttributes); return(MvcHtmlString.Create(lnk.ToString().Replace(repID, linktext))); }
public static MvcHtmlString GenerateAlphabeticalActionLink(this AjaxHelper helper, string actionName, string controllerName, string AreaName, AjaxOptions ajaxOptions) { var sb = new StringBuilder(); for (int i = 65; i <= 90; i++) { string charlink = Convert.ToChar(i).ToString(); sb.Append("<span class=\"pageActiveLink\">"); sb.Append(helper.ActionLink(charlink, "Index", new { controller = controllerName, Area = AreaName, @id = charlink }, ajaxOptions)); sb.Append("</span>"); } return(MvcHtmlString.Create(sb.ToString())); }
public void ActionLinkWithOptions() { // Arrange AjaxHelper ajaxHelper = GetAjaxHelper(); // Act MvcHtmlString actionLink = ajaxHelper.ActionLink("linkText", "Action", "Controller", new AjaxOptions { UpdateTargetId = "some-id" }); // Assert Assert.AreEqual(@"<a href=""" + MvcHelper.AppPathModifier + @"/app/Controller/Action"" onclick=""Sys.Mvc.AsyncHyperlink.handleClick(this, new Sys.UI.DomEvent(event), { insertionMode: Sys.Mvc.InsertionMode.replace, updateTargetId: 'some-id' });"">linkText</a>", actionLink.ToHtmlString()); }
public void ActionLinkWithProtocol() { // Arrange AjaxHelper ajaxHelper = GetAjaxHelper(); // Act string actionLink = ajaxHelper.ActionLink("linkText", "Action", "Controller", "https", null, null, null, new AjaxOptions { UpdateTargetId = "some-id" }, null); // Assert Assert.AreEqual(@"<a href=""https://foo.bar.baz" + HtmlHelperTest.AppPathModifier + @"/app/Controller/Action"" onclick=""Sys.Mvc.AsyncHyperlink.handleClick(this, new Sys.UI.DomEvent(event), { insertionMode: Sys.Mvc.InsertionMode.replace, updateTargetId: 'some-id' });"">linkText</a>", actionLink); }
public static MvcHtmlString AjaxActionLink(this AjaxHelper ajaxHelper, string linkText, string actionName, string controllerName, object routeValues, AjaxOptions ajaxOptions, object htmlAttributes, string iconCss = "") { var repID = Guid.NewGuid().ToString(); var lnk = ajaxHelper.ActionLink(repID, actionName, controllerName, routeValues, ajaxOptions, htmlAttributes); var builder = new TagBuilder("span"); builder.MergeAttribute("class", iconCss); MvcHtmlString result = MvcHtmlString.Create(lnk.ToString().Replace(repID, builder.ToString() + linkText)); return(result); }
public static MvcHtmlString ImageActionLink(this AjaxHelper helper, string imageUrl, string altText, string actionName, object routeValues, System.Web.Mvc.Ajax.AjaxOptions ajaxOptions, object htmlAtributes) { var builder = new TagBuilder("img"); builder.MergeAttribute("src", imageUrl); builder.MergeAttribute("alt", altText); var link = helper.ActionLink("[replaceme]", actionName, routeValues, ajaxOptions, htmlAtributes); return(MvcHtmlString.Create( link.ToHtmlString().Replace("[replaceme]", string.Concat("<imgLabel>", altText, "</imgLabel>", builder.ToString(TagRenderMode.SelfClosing)) ) )); }