Exemplo n.º 1
0
        /// <summary>
        ///   Creates a HTML hyperlink from given text and action
        /// </summary>
        /// <param name="html">Current html helper object</param>
        /// <param name="linkText">Link text</param>
        /// <param name="result">Action result</param>
        /// <param name="htmlAttributes">[Optional] Extra HTML attributes</param>
        /// <returns>HTML hyperlink</returns>
        public static IExtendedHtmlString Hyperlink(
            this HtmlHelper html,
            string linkText,
            ActionResult result,
            object htmlAttributes = null)
        {
            string link = WebExtrasMvcUtilT4.GetUrl(html, result);

            return(html.Hyperlink(linkText, link, htmlAttributes));
        }
Exemplo n.º 2
0
        /// <summary>
        ///   Create a HTML hyperlink with an image and given action
        /// </summary>
        /// <param name="html">Current HTML helper object</param>
        /// <param name="src">Image location</param>
        /// <param name="altText">Image alt text</param>
        /// <param name="title">Image title</param>
        /// <param name="result">Action result</param>
        /// <param name="htmlAttributes">
        ///   [Optional] Extra html attributes for the image link. By default
        ///   these attributes will be applied to the A tag only.
        /// </param>
        /// <returns>HTML image hyperlink</returns>
        public static IExtendedHtmlString Imagelink(
            this HtmlHelper html,
            string src,
            string altText,
            string title,
            ActionResult result,
            object htmlAttributes = null)
        {
            string url = WebExtrasMvcUtilT4.GetUrl(html, result);

            return(html.Imagelink(src, altText, title, url, htmlAttributes));
        }
Exemplo n.º 3
0
        /// <summary>
        ///   Creates a HTML hyperlink from given text and action
        /// </summary>
        /// <param name="html">Current html helper object</param>
        /// <param name="user">User used to authenticate</param>
        /// <param name="linkText">Link text</param>
        /// <param name="result">Action result</param>
        /// <param name="htmlAttributes">[Optional] Extra HTML attributes</param>
        /// <returns>HTML hyperlink</returns>
        public static IExtendedHtmlString AuthHyperlink(
            this HtmlHelper html,
            IPrincipal user,
            string linkText,
            ActionResult result,
            object htmlAttributes = null)
        {
            if (!user.Identity.IsAuthenticated)
            {
                return(ExtendedHtmlString.Empty);
            }

            string url = WebExtrasMvcUtilT4.GetUrl(html, result);

            return(html.Hyperlink(linkText, url, htmlAttributes));
        }