private static IHtmlContent AjaxLinkInner(this IHtmlHelper helper, string linkText, string actionName,
                                                  string actionController, AjaxLink ajaxlinkProperties,
                                                  object routedValues   = null,
                                                  object htmlAttributes = null)
        {
            var urlHelper = new UrlHelper(helper.ViewContext);
            var url       = urlHelper.Action(actionName, actionController, routedValues ?? new RouteValueDictionary());

            var customAttributes = HtmlHelper.AnonymousObjectToHtmlAttributes(htmlAttributes ?? new object());

            customAttributes.Add("data-ajax-url", url);
            if (ajaxlinkProperties != null)
            {
                customAttributes.Add("data-dialog-title", ajaxlinkProperties.DialogTitle);
                customAttributes.Add("data-dialog-width", ajaxlinkProperties.DialogWidth + "px");
            }

            var tagBuilder = new TagBuilder("a");

            tagBuilder.MergeAttributes(customAttributes);
            tagBuilder.InnerHtml.AppendHtmlLine(linkText);

            using (var writer = new StringWriter())
            {
                tagBuilder.WriteTo(writer, HtmlEncoder.Default);
                return(new HtmlString(writer.ToString()));
            }
        }
 public static IHtmlContent AjaxLink(this IHtmlHelper helper, string linkText, string actionName, string actionController, AjaxLink ajaxLinkProperties, object htmlAttributes)
 {
     return(AjaxLinkInner(helper, linkText, actionName, actionController, ajaxLinkProperties, htmlAttributes: htmlAttributes));
 }
 public static IHtmlContent AjaxLink(this IHtmlHelper helper, string linkText, string actionName, AjaxLink ajaxLinkProperties)
 {
     return(AjaxLinkInner(helper, linkText, actionName, null, ajaxLinkProperties));
 }