Ejemplo n.º 1
0
        public string ToHtmlString()
        {
            var mergedHtmlAttributes = _htmlAttributes;

            if (!string.IsNullOrEmpty(_id))
            {
                mergedHtmlAttributes.AddIfNotExist("id", _id);
            }
            if (_disabled)
            {
                mergedHtmlAttributes.AddOrMergeCssClass("class", "disabled");
            }

            var linkBuilder = new TagBuilder("a");

            linkBuilder.MergeAttributes(mergedHtmlAttributes);
            linkBuilder.MergeAttribute("href", _url);

            if (_iconPrepend != Icons._not_set || _iconAppend != Icons._not_set || !string.IsNullOrEmpty(_iconPrependCustomClass) || !string.IsNullOrEmpty(_iconAppendCustomClass))
            {
                var iPrependString = string.Empty;
                var iAppendString  = string.Empty;

                if (_iconPrepend != Icons._not_set)
                {
                    iPrependString = new BootstrapIcon(_iconPrepend, _iconPrependIsWhite).ToHtmlString() + " ";
                }
                if (_iconAppend != Icons._not_set)
                {
                    iAppendString = " " + new BootstrapIcon(_iconAppend, _iconAppendIsWhite).ToHtmlString();
                }
                if (!string.IsNullOrEmpty(_iconPrependCustomClass))
                {
                    var i = new TagBuilder("i");
                    i.AddCssClass(_iconPrependCustomClass);
                    iPrependString = i.ToString(TagRenderMode.Normal) + " ";
                }
                if (!string.IsNullOrEmpty(_iconAppendCustomClass))
                {
                    var i = new TagBuilder("i");
                    i.AddCssClass(_iconAppendCustomClass);
                    iAppendString = " " + i.ToString(TagRenderMode.Normal);
                }

                _linkText = iPrependString + _linkText + iAppendString;
            }

            linkBuilder.InnerHtml = _linkText;

            string input = linkBuilder.ToString(TagRenderMode.Normal);

            if (!string.IsNullOrEmpty(_wrapTag))
            {
                input = string.Format("<{0}>{1}</{0}>", _wrapTag, input);
            }

            return(MvcHtmlString.Create(input).ToString());
        }
Ejemplo n.º 2
0
        public string ToHtmlString()
        {
            var mergedHtmlAttributes = htmlAttributes;

            if (!string.IsNullOrEmpty(id))
            {
                mergedHtmlAttributes.AddIfNotExist("id", id);
            }
            if (disabled)
            {
                mergedHtmlAttributes.AddOrMergeCssClass("class", "disabled");
            }

            var linkBuilder = new TagBuilder("a");

            linkBuilder.MergeAttributes(mergedHtmlAttributes);
            linkBuilder.MergeAttribute("href", url);

            if (this.iconPrepend != Icons._not_set || this.iconAppend != Icons._not_set)
            {
                string iPrependString = string.Empty;
                string iAppendString  = string.Empty;

                if (this.iconPrepend != Icons._not_set)
                {
                    iPrependString = new BootstrapIcon(this.iconPrepend, this.iconPrependIsWhite).ToHtmlString() + " ";
                }
                if (this.iconAppend != Icons._not_set)
                {
                    iAppendString = " " + new BootstrapIcon(this.iconAppend, this.iconAppendIsWhite).ToHtmlString();
                }

                linkText = iPrependString + linkText + iAppendString;
            }

            linkBuilder.InnerHtml = linkText;

            string input = linkBuilder.ToString(TagRenderMode.Normal);

            if (!string.IsNullOrEmpty(this.wrapTag))
            {
                input = string.Format("<{0}>{1}</{0}>", this.wrapTag, input);
            }

            return(MvcHtmlString.Create(input).ToString());
        }
        public override string ToHtmlString()
        {
            var mergedHtmlAttributes = _model.htmlAttributes;

            mergedHtmlAttributes.AddOrMergeCssClass("class", "btn");
            if (!string.IsNullOrEmpty(_model.id))
            {
                mergedHtmlAttributes.AddIfNotExist("id", _model.id);
            }

            mergedHtmlAttributes.AddOrMergeCssClass("class", BootstrapHelper.GetClassForButtonSize(_model.size));
            mergedHtmlAttributes.AddOrMergeCssClass("class", BootstrapHelper.GetClassForButtonStyle(_model.style));

            if (_model.buttonBlock)
            {
                mergedHtmlAttributes.AddOrMergeCssClass("class", "btn-block");
            }
            if (_model.isDropDownToggle)
            {
                mergedHtmlAttributes.AddOrMergeCssClass("class", "dropdown-toggle");
                mergedHtmlAttributes.AddIfNotExist("data-toggle", "dropdown");
            }
            if (_model.disabled)
            {
                mergedHtmlAttributes.AddOrMergeCssClass("class", "disabled");
            }

            var input = string.Empty;

            if (_model.iconPrepend != Icons._not_set || _model.iconAppend != Icons._not_set || !string.IsNullOrEmpty(_model.iconPrependCustomClass) || !string.IsNullOrEmpty(_model.iconAppendCustomClass))
            {
                string iPrependString = string.Empty;
                string iAppendString  = string.Empty;
                if (_model.iconPrepend != Icons._not_set)
                {
                    iPrependString = new BootstrapIcon(_model.iconPrepend, _model.iconPrependIsWhite).ToHtmlString();
                }
                if (_model.iconAppend != Icons._not_set)
                {
                    iAppendString = new BootstrapIcon(_model.iconAppend, _model.iconAppendIsWhite).ToHtmlString();
                }
                if (!string.IsNullOrEmpty(_model.iconPrependCustomClass))
                {
                    var i = new TagBuilder("i");
                    i.AddCssClass(_model.iconPrependCustomClass);
                    iPrependString = i.ToString(TagRenderMode.Normal);
                }
                if (!string.IsNullOrEmpty(_model.iconAppendCustomClass))
                {
                    var i = new TagBuilder("i");
                    i.AddCssClass(_model.iconAppendCustomClass);
                    iPrependString = i.ToString(TagRenderMode.Normal);
                }

                string combined =
                    iPrependString +
                    (!string.IsNullOrEmpty(iPrependString) && (!string.IsNullOrEmpty(_model.text) || !string.IsNullOrEmpty(iAppendString)) ? " " : "") +
                    _model.text +
                    (!string.IsNullOrEmpty(iAppendString) && (!string.IsNullOrEmpty(_model.text) || !string.IsNullOrEmpty(iPrependString)) ? " " : "") +
                    iAppendString;

                string holder = Guid.NewGuid().ToString();

                input = GenerateActionLink(holder, mergedHtmlAttributes);
                input = input.Replace(holder, combined);
            }
            else
            {
                input = GenerateActionLink(_model.text, mergedHtmlAttributes);
            }

            return(MvcHtmlString.Create(input).ToString());
        }
Ejemplo n.º 4
0
        public virtual string ToHtmlString()
        {
            var input = new TagBuilder("button");

            input.Attributes.Add("type", _model.type);
            if (!string.IsNullOrEmpty(_model.name))
            {
                input.Attributes.Add("name", _model.name);
            }
            if (!string.IsNullOrEmpty(_model.id))
            {
                input.Attributes.Add("id", _model.id);
            }
            if (!string.IsNullOrEmpty(_model.value))
            {
                input.Attributes.Add("value", _model.value);
            }
            input.MergeAttributes(_model.htmlAttributes.FormatHtmlAttributes());
            input.AddCssClass(BootstrapHelper.GetClassForButtonSize(_model.size));
            input.AddCssClass(BootstrapHelper.GetClassForButtonStyle(_model.style));
            if (_model.buttonBlock)
            {
                input.AddCssClass("btn-block");
            }
            if (_model.isDropDownToggle)
            {
                input.AddCssClass("dropdown-toggle");
                input.AddOrMergeAttribute("data-toggle", "dropdown");
            }
            if (_model.disabled)
            {
                input.AddCssClass("disabled");
                input.AddOrMergeAttribute("disabled", "");
            }

            if (!string.IsNullOrEmpty(_model.loadingText))
            {
                input.AddOrMergeAttribute("data-loading-text", _model.loadingText);
            }
            input.AddCssClass("btn");

            if (_withCaret)
            {
                if (!string.IsNullOrEmpty(_model.text))
                {
                    _model.text += " ";
                }
                _model.text += "<span class='caret'></span>";
            }

            if (_model.iconPrepend != Icons._not_set || _model.iconAppend != Icons._not_set || !string.IsNullOrEmpty(_model.iconPrependCustomClass) || !string.IsNullOrEmpty(_model.iconAppendCustomClass))
            {
                var iPrependString = string.Empty;
                var iAppendString  = string.Empty;
                if (_model.iconPrepend != Icons._not_set)
                {
                    iPrependString = new BootstrapIcon(_model.iconPrepend, _model.iconPrependIsWhite).ToHtmlString();
                }
                if (_model.iconAppend != Icons._not_set)
                {
                    iAppendString = new BootstrapIcon(_model.iconAppend, _model.iconAppendIsWhite).ToHtmlString();
                }
                if (!string.IsNullOrEmpty(_model.iconPrependCustomClass))
                {
                    var i = new TagBuilder("i");
                    i.AddCssClass(_model.iconPrependCustomClass);
                    iPrependString = i.ToString(TagRenderMode.Normal);
                }
                if (!string.IsNullOrEmpty(_model.iconAppendCustomClass))
                {
                    var i = new TagBuilder("i");
                    i.AddCssClass(_model.iconAppendCustomClass);
                    iAppendString = i.ToString(TagRenderMode.Normal);
                }

                _model.text =
                    iPrependString +
                    (!string.IsNullOrEmpty(iPrependString) && (!string.IsNullOrEmpty(_model.text) || !string.IsNullOrEmpty(iAppendString)) ? " " : "") +
                    _model.text +
                    (!string.IsNullOrEmpty(iAppendString) && (!string.IsNullOrEmpty(_model.text) || !string.IsNullOrEmpty(iPrependString)) ? " " : "") +
                    iAppendString;
            }

            input.InnerHtml = _model.text;
            return(input.ToString());
        }
        public string ToHtmlString()
        {
            var mergedHtmlAttributes = _htmlAttributes;
            if (!string.IsNullOrEmpty(_id)) mergedHtmlAttributes.AddIfNotExist("id", _id);
            if (_disabled) mergedHtmlAttributes.AddOrMergeCssClass("class", "disabled");

            var linkBuilder = new TagBuilder("a");
            linkBuilder.MergeAttributes(mergedHtmlAttributes);
            linkBuilder.MergeAttribute("href", _url);

            if (_iconPrepend != Icons._not_set || _iconAppend != Icons._not_set || !string.IsNullOrEmpty(_iconPrependCustomClass) || !string.IsNullOrEmpty(_iconAppendCustomClass))
            {
                var iPrependString = string.Empty;
                var iAppendString = string.Empty;

                if (_iconPrepend != Icons._not_set) iPrependString = new BootstrapIcon(_iconPrepend, _iconPrependIsWhite).ToHtmlString() + " ";
                if (_iconAppend != Icons._not_set) iAppendString = " " + new BootstrapIcon(_iconAppend, _iconAppendIsWhite).ToHtmlString();
                if (!string.IsNullOrEmpty(_iconPrependCustomClass))
                {
                    var i = new TagBuilder("i");
                    i.AddCssClass(_iconPrependCustomClass);
                    iPrependString = i.ToString(TagRenderMode.Normal) + " ";
                }
                if (!string.IsNullOrEmpty(_iconAppendCustomClass))
                {
                    var i = new TagBuilder("i");
                    i.AddCssClass(_iconAppendCustomClass);
                    iAppendString = " " + i.ToString(TagRenderMode.Normal);
                }

                _linkText = iPrependString + _linkText + iAppendString;
            }

            linkBuilder.InnerHtml = _linkText;

            string input = linkBuilder.ToString(TagRenderMode.Normal);
            if (!string.IsNullOrEmpty(_wrapTag)) input = string.Format("<{0}>{1}</{0}>", _wrapTag, input);

            return MvcHtmlString.Create(input).ToString();
        }
        public string ToHtmlString()
        {
            var mergedHtmlAttributes = _htmlAttributes;
            if (!string.IsNullOrEmpty(_id)) mergedHtmlAttributes.AddIfNotExist("id", _id);

            if (_isDropDownToggle)
            {
                mergedHtmlAttributes.AddOrMergeCssClass("class", "dropdown-toggle");
                mergedHtmlAttributes.AddIfNotExist("data-toggle", "dropdown");
            }
            if (_disabled) mergedHtmlAttributes.AddOrMergeCssClass("class", "disabled");

            var input = string.Empty;
            string iPrependString = string.Empty;
            string iAppendString = string.Empty;

            if (this._iconPrepend != Icons._not_set || this._iconAppend != Icons._not_set)
            {
                if (this._iconPrepend != Icons._not_set) iPrependString = new BootstrapIcon(this._iconPrepend, this._iconPrependIsWhite).ToHtmlString() + " ";
                if (this._iconAppend != Icons._not_set) iAppendString = " " + new BootstrapIcon(this._iconAppend, this._iconAppendIsWhite).ToHtmlString();

                _linkText = "{0}" + _linkText + "{1}";
            }

            switch (this._actionTypePassed)
            {
                case ActionTypePassed.HtmlRegular:
                    input = html.ActionLink(_linkText, _actionName, _controllerName, _protocol, _hostName, _fragment, _routeValues, mergedHtmlAttributes).ToHtmlString();
                    break;
                case ActionTypePassed.HtmlActionResult:
                    input = html.ActionLink(_linkText, _result, mergedHtmlAttributes, _protocol, _hostName, _fragment).ToHtmlString();
                    break;
                case ActionTypePassed.HtmlTaskResult:
                    input = html.ActionLink(_linkText, _taskResult, mergedHtmlAttributes, _protocol, _hostName, _fragment).ToHtmlString();
                    break;
                case ActionTypePassed.AjaxRegular:
                    input = ajax.ActionLink(_linkText, _actionName, _controllerName, _protocol, _hostName, _fragment, _routeValues, _ajaxOptions, mergedHtmlAttributes).ToHtmlString();
                    break;
                case ActionTypePassed.AjaxActionResult:
                    input = ajax.ActionLink(_linkText, _result, _ajaxOptions, mergedHtmlAttributes).ToHtmlString();
                    break;
                case ActionTypePassed.AjaxTaskResult:
                    input = ajax.ActionLink(_linkText, _taskResult, _ajaxOptions, mergedHtmlAttributes).ToHtmlString();
                    break;
                default:
                    break;
            }

            input = string.Format(input, iPrependString, iAppendString);

            if (!string.IsNullOrEmpty(this._wrapTag)) input = string.Format("<{0}>{1}</{0}>", this._wrapTag, input);

            return MvcHtmlString.Create(input).ToString();
        }
        public string ToHtmlString()
        {
            var mergedHtmlAttributes = _htmlAttributes;
            if (!string.IsNullOrEmpty(_id)) mergedHtmlAttributes.AddIfNotExist("id", _id);

            if (_isDropDownToggle)
            {
                mergedHtmlAttributes.AddOrMergeCssClass("class", "dropdown-toggle");
                mergedHtmlAttributes.AddIfNotExist("data-toggle", "dropdown");
            }
            if (_disabled) mergedHtmlAttributes.AddOrMergeCssClass("class", "disabled");
            if (!string.IsNullOrEmpty(_title)) mergedHtmlAttributes.AddOrReplace("title", _title);

            var input = string.Empty;
            var iPrependString = string.Empty;
            var iAppendString = string.Empty;

            if (_iconPrepend != Icons._not_set || _iconAppend != Icons._not_set || !string.IsNullOrEmpty(_iconPrependCustomClass) || !string.IsNullOrEmpty(_iconAppendCustomClass))
            {
                if (_iconPrepend != Icons._not_set) iPrependString = new BootstrapIcon(_iconPrepend, _iconPrependIsWhite).ToHtmlString() + " ";
                if (_iconAppend != Icons._not_set) iAppendString = " " + new BootstrapIcon(_iconAppend, _iconAppendIsWhite).ToHtmlString();
                if (!string.IsNullOrEmpty(_iconPrependCustomClass))
                {
                    var i = new TagBuilder("i");
                    i.AddCssClass(_iconPrependCustomClass);
                    iPrependString = i.ToString(TagRenderMode.Normal) + " ";
                }
                if (!string.IsNullOrEmpty(_iconAppendCustomClass))
                {
                    var i = new TagBuilder("i");
                    i.AddCssClass(_iconAppendCustomClass);
                    iAppendString = " " + i.ToString(TagRenderMode.Normal);
                }
                _linkText = "{0}" + _linkText + "{1}";
            }

            var requestedController = "";
            var requestedAction = "";
            var requestedArea = "";

            switch (_actionTypePassed)
            {
                case ActionTypePassed.HtmlRegular:
                    requestedArea = _routeValues != null && _routeValues.ContainsKey("area") ? _routeValues["area"].ToString() : html.ViewContext.RouteData.DataTokens.ContainsKey("area") ? html.ViewContext.RouteData.DataTokens["area"].ToString() : string.Empty;
                    requestedController = string.IsNullOrEmpty(_controllerName) ? html.ViewContext.RouteData.GetRequiredString("controller") : _controllerName;
                    requestedAction = _actionName;
                    input = html.ActionLink(_linkText, _actionName, _controllerName, _protocol, _hostName, _fragment, _routeValues, mergedHtmlAttributes).ToHtmlString();
                    break;
                case ActionTypePassed.HtmlActionResult:
                    requestedArea = _result.GetRouteValueDictionary().ContainsKey("area") ? _result.GetRouteValueDictionary()["area"].ToString() : string.Empty;
                    requestedController = _result.GetRouteValueDictionary()["controller"].ToString();
                    requestedAction = _result.GetRouteValueDictionary()["action"].ToString();
                    input = html.ActionLink(_linkText, _result, mergedHtmlAttributes, _protocol, _hostName, _fragment).ToHtmlString();
                    break;
                case ActionTypePassed.HtmlTaskResult:
                    requestedArea = _taskResult.Result.GetRouteValueDictionary().ContainsKey("area") ? _taskResult.Result.GetRouteValueDictionary()["area"].ToString() : string.Empty;
                    requestedController = _taskResult.Result.GetRouteValueDictionary()["controller"].ToString();
                    requestedAction = _taskResult.Result.GetRouteValueDictionary()["action"].ToString();
                    input = html.ActionLink(_linkText, _taskResult, mergedHtmlAttributes, _protocol, _hostName, _fragment).ToHtmlString();
                    break;
                case ActionTypePassed.AjaxRegular:
                    requestedArea = _routeValues != null && _routeValues.ContainsKey("area") ? _routeValues["area"].ToString() : ajax.ViewContext.RouteData.DataTokens.ContainsKey("area") ? ajax.ViewContext.RouteData.DataTokens["area"].ToString() : string.Empty;
                    requestedController = string.IsNullOrEmpty(_controllerName) ? ajax.ViewContext.RouteData.GetRequiredString("controller") : _controllerName;
                    requestedAction = _actionName;
                    input = ajax.ActionLink(_linkText, _actionName, _controllerName, _protocol, _hostName, _fragment, _routeValues, _ajaxOptions, mergedHtmlAttributes).ToHtmlString();
                    break;
                case ActionTypePassed.AjaxActionResult:
                    requestedArea = _result.GetRouteValueDictionary().ContainsKey("area") ? _result.GetRouteValueDictionary()["area"].ToString() : string.Empty;
                    requestedController = _result.GetRouteValueDictionary()["controller"].ToString();
                    requestedAction = _result.GetRouteValueDictionary()["action"].ToString();
                    input = ajax.ActionLink(_linkText, _result, _ajaxOptions, mergedHtmlAttributes).ToHtmlString();
                    break;
                case ActionTypePassed.AjaxTaskResult:
                    requestedArea = _taskResult.Result.GetRouteValueDictionary().ContainsKey("area") ? _taskResult.Result.GetRouteValueDictionary()["area"].ToString() : string.Empty;
                    requestedController = _taskResult.Result.GetRouteValueDictionary()["controller"].ToString();
                    requestedAction = _taskResult.Result.GetRouteValueDictionary()["action"].ToString();
                    input = ajax.ActionLink(_linkText, _taskResult, _ajaxOptions, mergedHtmlAttributes).ToHtmlString();
                    break;
            }

            input = string.Format(input, iPrependString, iAppendString);

            if (!string.IsNullOrEmpty(_wrapTag))
            {
                var currentAction = string.Empty;
                var currentController = string.Empty;
                var currentArea = string.Empty;
                switch (_actionTypePassed)
                {
                    case ActionTypePassed.HtmlRegular:
                    case ActionTypePassed.HtmlActionResult:
                    case ActionTypePassed.HtmlTaskResult:
                        currentAction = html.ViewContext.RouteData.GetRequiredString("action");
                        currentController = html.ViewContext.RouteData.GetRequiredString("controller");
                        currentArea = html.ViewContext.RouteData.DataTokens.ContainsKey("area") ? html.ViewContext.RouteData.DataTokens["area"].ToString() : string.Empty;
                        break;
                    case ActionTypePassed.AjaxRegular:
                    case ActionTypePassed.AjaxActionResult:
                    case ActionTypePassed.AjaxTaskResult:
                        currentAction = ajax.ViewContext.RouteData.GetRequiredString("action");
                        currentController = ajax.ViewContext.RouteData.GetRequiredString("controller");
                        currentArea = ajax.ViewContext.RouteData.DataTokens.ContainsKey("area") ? ajax.ViewContext.RouteData.DataTokens["area"].ToString() : string.Empty;
                        break;
                }

                var classActive = "";
                if (_wrapTagControllerAware && currentArea == requestedArea && currentController == requestedController) classActive = @" class=""active""";
                if (_wrapTagControllerAndActionAware && currentArea == requestedArea && currentController == requestedController && currentAction == requestedAction) classActive = @" class=""active""";
                input = string.Format("<{0}{1}>{2}</{0}>", _wrapTag, classActive, input);
            }

            return MvcHtmlString.Create(input).ToString();
        }
        public string ToHtmlString()
        {
            var mergedHtmlAttributes = _htmlAttributes;

            if (!string.IsNullOrEmpty(_id))
            {
                mergedHtmlAttributes.AddIfNotExist("id", _id);
            }

            if (_isDropDownToggle)
            {
                mergedHtmlAttributes.AddOrMergeCssClass("class", "dropdown-toggle");
                mergedHtmlAttributes.AddIfNotExist("data-toggle", "dropdown");
            }
            if (_disabled)
            {
                mergedHtmlAttributes.AddOrMergeCssClass("class", "disabled");
            }
            if (!string.IsNullOrEmpty(_title))
            {
                mergedHtmlAttributes.AddOrReplace("title", _title);
            }

            var input          = string.Empty;
            var iPrependString = string.Empty;
            var iAppendString  = string.Empty;

            if (_iconPrepend != Icons._not_set || _iconAppend != Icons._not_set || !string.IsNullOrEmpty(_iconPrependCustomClass) || !string.IsNullOrEmpty(_iconAppendCustomClass))
            {
                if (_iconPrepend != Icons._not_set)
                {
                    iPrependString = new BootstrapIcon(_iconPrepend, _iconPrependIsWhite).ToHtmlString() + " ";
                }
                if (_iconAppend != Icons._not_set)
                {
                    iAppendString = " " + new BootstrapIcon(_iconAppend, _iconAppendIsWhite).ToHtmlString();
                }
                if (!string.IsNullOrEmpty(_iconPrependCustomClass))
                {
                    var i = new TagBuilder("i");
                    i.AddCssClass(_iconPrependCustomClass);
                    iPrependString = i.ToString(TagRenderMode.Normal) + " ";
                }
                if (!string.IsNullOrEmpty(_iconAppendCustomClass))
                {
                    var i = new TagBuilder("i");
                    i.AddCssClass(_iconAppendCustomClass);
                    iAppendString = " " + i.ToString(TagRenderMode.Normal);
                }
                _linkText = "{0}" + _linkText + "{1}";
            }

            var requestedController = "";
            var requestedAction     = "";
            var requestedArea       = "";

            switch (_actionTypePassed)
            {
            case ActionTypePassed.HtmlRegular:
                requestedArea       = _routeValues != null && _routeValues.ContainsKey("area") ? _routeValues["area"].ToString() : html.ViewContext.RouteData.DataTokens.ContainsKey("area") ? html.ViewContext.RouteData.DataTokens["area"].ToString() : string.Empty;
                requestedController = string.IsNullOrEmpty(_controllerName) ? html.ViewContext.RouteData.GetRequiredString("controller") : _controllerName;
                requestedAction     = _actionName;
                input = html.ActionLink(_linkText, _actionName, _controllerName, _protocol, _hostName, _fragment, _routeValues, mergedHtmlAttributes).ToHtmlString();
                break;

            case ActionTypePassed.HtmlActionResult:
                requestedArea       = _result.GetRouteValueDictionary().ContainsKey("area") ? _result.GetRouteValueDictionary()["area"].ToString() : string.Empty;
                requestedController = _result.GetRouteValueDictionary()["controller"].ToString();
                requestedAction     = _result.GetRouteValueDictionary()["action"].ToString();
                input = html.ActionLink(_linkText, _result, mergedHtmlAttributes, _protocol, _hostName, _fragment).ToHtmlString();
                break;

            case ActionTypePassed.HtmlTaskResult:
                requestedArea       = _taskResult.Result.GetRouteValueDictionary().ContainsKey("area") ? _taskResult.Result.GetRouteValueDictionary()["area"].ToString() : string.Empty;
                requestedController = _taskResult.Result.GetRouteValueDictionary()["controller"].ToString();
                requestedAction     = _taskResult.Result.GetRouteValueDictionary()["action"].ToString();
                input = html.ActionLink(_linkText, _taskResult, mergedHtmlAttributes, _protocol, _hostName, _fragment).ToHtmlString();
                break;

            case ActionTypePassed.AjaxRegular:
                requestedArea       = _routeValues != null && _routeValues.ContainsKey("area") ? _routeValues["area"].ToString() : ajax.ViewContext.RouteData.DataTokens.ContainsKey("area") ? ajax.ViewContext.RouteData.DataTokens["area"].ToString() : string.Empty;
                requestedController = string.IsNullOrEmpty(_controllerName) ? ajax.ViewContext.RouteData.GetRequiredString("controller") : _controllerName;
                requestedAction     = _actionName;
                input = ajax.ActionLink(_linkText, _actionName, _controllerName, _protocol, _hostName, _fragment, _routeValues, _ajaxOptions, mergedHtmlAttributes).ToHtmlString();
                break;

            case ActionTypePassed.AjaxActionResult:
                requestedArea       = _result.GetRouteValueDictionary().ContainsKey("area") ? _result.GetRouteValueDictionary()["area"].ToString() : string.Empty;
                requestedController = _result.GetRouteValueDictionary()["controller"].ToString();
                requestedAction     = _result.GetRouteValueDictionary()["action"].ToString();
                input = ajax.ActionLink(_linkText, _result, _ajaxOptions, mergedHtmlAttributes).ToHtmlString();
                break;

            case ActionTypePassed.AjaxTaskResult:
                requestedArea       = _taskResult.Result.GetRouteValueDictionary().ContainsKey("area") ? _taskResult.Result.GetRouteValueDictionary()["area"].ToString() : string.Empty;
                requestedController = _taskResult.Result.GetRouteValueDictionary()["controller"].ToString();
                requestedAction     = _taskResult.Result.GetRouteValueDictionary()["action"].ToString();
                input = ajax.ActionLink(_linkText, _taskResult, _ajaxOptions, mergedHtmlAttributes).ToHtmlString();
                break;
            }

            input = string.Format(input, iPrependString, iAppendString);

            if (!string.IsNullOrEmpty(_wrapTag))
            {
                var currentAction     = string.Empty;
                var currentController = string.Empty;
                var currentArea       = string.Empty;
                switch (_actionTypePassed)
                {
                case ActionTypePassed.HtmlRegular:
                case ActionTypePassed.HtmlActionResult:
                case ActionTypePassed.HtmlTaskResult:
                    currentAction     = html.ViewContext.RouteData.GetRequiredString("action");
                    currentController = html.ViewContext.RouteData.GetRequiredString("controller");
                    currentArea       = html.ViewContext.RouteData.DataTokens.ContainsKey("area") ? html.ViewContext.RouteData.DataTokens["area"].ToString() : string.Empty;
                    break;

                case ActionTypePassed.AjaxRegular:
                case ActionTypePassed.AjaxActionResult:
                case ActionTypePassed.AjaxTaskResult:
                    currentAction     = ajax.ViewContext.RouteData.GetRequiredString("action");
                    currentController = ajax.ViewContext.RouteData.GetRequiredString("controller");
                    currentArea       = ajax.ViewContext.RouteData.DataTokens.ContainsKey("area") ? ajax.ViewContext.RouteData.DataTokens["area"].ToString() : string.Empty;
                    break;
                }

                var classActive = "";
                if (_wrapTagControllerAware && currentArea == requestedArea && currentController == requestedController)
                {
                    classActive = @" class=""active""";
                }
                if (_wrapTagControllerAndActionAware && currentArea == requestedArea && currentController == requestedController && currentAction == requestedAction)
                {
                    classActive = @" class=""active""";
                }
                input = string.Format("<{0}{1}>{2}</{0}>", _wrapTag, classActive, input);
            }

            return(MvcHtmlString.Create(input).ToString());
        }
        public string ToHtmlString()
        {
            var mergedHtmlAttributes = htmlAttributes;

            if (!string.IsNullOrEmpty(id))
            {
                mergedHtmlAttributes.AddIfNotExist("id", id);
            }

            if (isDropDownToggle)
            {
                mergedHtmlAttributes.AddOrMergeCssClass("class", "dropdown-toggle");
                mergedHtmlAttributes.AddIfNotExist("data-toggle", "dropdown");
            }
            if (disabled)
            {
                mergedHtmlAttributes.AddOrMergeCssClass("class", "disabled");
            }

            var    input          = string.Empty;
            string iPrependString = string.Empty;
            string iAppendString  = string.Empty;

            if (this.iconPrepend != Icons._not_set || this.iconAppend != Icons._not_set)
            {
                if (this.iconPrepend != Icons._not_set)
                {
                    iPrependString = new BootstrapIcon(this.iconPrepend, this.iconPrependIsWhite).ToHtmlString() + " ";
                }
                if (this.iconAppend != Icons._not_set)
                {
                    iAppendString = " " + new BootstrapIcon(this.iconAppend, this.iconAppendIsWhite).ToHtmlString();
                }

                linkText = "{0}" + linkText + "{1}";
            }

            switch (this.actionTypePassed)
            {
            case ActionTypePassed.HtmlRegular:
                input = html.ActionLink(linkText, actionName, controllerName, protocol, hostName, fragment, routeValues, mergedHtmlAttributes).ToHtmlString();
                break;

            case ActionTypePassed.HtmlActionResult:
                input = html.ActionLink(linkText, result, mergedHtmlAttributes, protocol, hostName, fragment).ToHtmlString();
                break;

            case ActionTypePassed.HtmlTaskResult:
                input = html.ActionLink(linkText, taskResult, mergedHtmlAttributes, protocol, hostName, fragment).ToHtmlString();
                break;

            case ActionTypePassed.AjaxRegular:
                input = ajax.ActionLink(linkText, actionName, controllerName, protocol, hostName, fragment, routeValues, ajaxOptions, mergedHtmlAttributes).ToHtmlString();
                break;

            case ActionTypePassed.AjaxActionResult:
                input = ajax.ActionLink(linkText, result, ajaxOptions, mergedHtmlAttributes).ToHtmlString();
                break;

            case ActionTypePassed.AjaxTaskResult:
                input = ajax.ActionLink(linkText, taskResult, ajaxOptions, mergedHtmlAttributes).ToHtmlString();
                break;

            default:
                break;
            }

            input = string.Format(input, iPrependString, iAppendString);

            if (!string.IsNullOrEmpty(this.wrapTag))
            {
                input = string.Format("<{0}>{1}</{0}>", this.wrapTag, input);
            }

            return(MvcHtmlString.Create(input).ToString());
        }