asp.net-mvc – 是否有一个ASP.NET MVC HtmlHelper的图像链接?

Html.RouteLink()HtmlHelper适用于文本链接.但是,连接图像的最佳方式是什么?

解决方法

这里是我的,它的核心功能使一些重载
public static string ImageLink(this HtmlHelper htmlHelper,string imgSrc,string alt,string actionName,string controllerName,object routeValues,object htmlAttributes,object imgHtmlAttributes)
    {
        UrlHelper urlHelper = ((Controller)htmlHelper.ViewContext.Controller).Url;
        string imgtag = htmlHelper.Image(imgSrc,alt,imgHtmlAttributes);
        string url = urlHelper.Action(actionName,controllerName,routeValues);



        TagBuilder imglink = new TagBuilder("a");
        imglink.MergeAttribute("href",url);
        imglink.InnerHtml =imgtag;
        imglink.MergeAttributes(new RouteValueDictionary(htmlAttributes),true);

        return imglink.ToString();

    }

相关文章

ASP.NET与IIS是紧密联系的,由于IIS6.0与IIS7.0的工作方式的...
在之前的ASP.NET是如何在IIS下工作的这篇文章中介绍了ASP.NE...
这篇文章主要讲解了“WPF如何实现带筛选功能的DataGrid”,文...
本篇内容介绍了“基于WPF如何实现3D画廊动画效果”的有关知识...
Some samples are below for ASP.Net web form controls:(fr...
问题描述: 对于未定义为 System.String 的列,唯一有效的值...