Attach image to ActionLink in MVC 4

前端 未结 4 1921
旧巷少年郎
旧巷少年郎 2021-01-14 01:33

I am using ActionLink with id in MVC 4 app and assinging actionLink id an image in css but on on earth I am doing wrong. is not working! here is my code

 <         


        
4条回答
  •  醉梦人生
    2021-01-14 02:11

    use your custom HtmlHelper:

        namespace Order.Web.UI.Infrastructure
    {
        public static class CustomHelpers
        {
            public static MvcHtmlString ImageActionLink(this HtmlHelper html, string imageSource, string url)
            {
                string imageActionLink = string.Format("",url,imageSource);
    
                return new MvcHtmlString(imageActionLink);
            }
        }
    }
    

    then in your view.cshtml:

    @using OrderPad2.Web.UI.Infrastructure
    .
    .
    .
    .
    @Html.ImageActionLink(@app.Icon,@app.AppStoreLink) 
    

提交回复
热议问题