Пример #1
0
        public static string ObtenerIcono(TipoIcono icono)
        {
            string clase = "";

            switch (icono)
            {
            case TipoIcono.Buscar: clase = "icon-search icon-white"; break;

            case TipoIcono.Guardar: clase = "icon-search icon-white"; break;
            }
            return(clase);
        }
Пример #2
0
        public static MvcHtmlString MTCBotonIconoModal(this HtmlHelper helper, string accion, string controlador, string idContenedor, TipoIcono icono = TipoIcono.Buscar, object routeValues = null)
        {
            var accionActual      = helper.ViewContext.RouteData.GetRequiredString("action");
            var controladorActual = helper.ViewContext.RouteData.GetRequiredString("controller");

            var imagen = new TagBuilder("i");

            imagen.AddCssClass(ObtenerIcono(icono));

            var urlHelper = new UrlHelper(helper.ViewContext.RequestContext);
            var link      = new TagBuilder("a")
            {
                InnerHtml = imagen.ToString()
            };

            if (string.IsNullOrEmpty(accion))
            {
                accion = accionActual;
            }
            if (string.IsNullOrEmpty(controlador))
            {
                controlador = controladorActual;
            }

            link.Attributes["data-url"] = urlHelper.Action(accion, controlador, routeValues);
            link.Attributes["href"]     = "#" + idContenedor;
            link.AddCssClass("btn btn-success modalMTC");

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