What's the best practice method for creating images that are hyperlinks in ASP.NET MVC with the html helpers (because I want to supply the controller/action parameters and let Routing create the full URL for me)?
This is what I've ended up with but I feel it's a bit rubbish and is the result of ages staring at it not being able to see the wood for the trees:
<a href="<%= ResolveUrl("~/") %>"><img src="<%= ResolveUrl开发者_运维技巧("~/Content/LogoCaption48.png") %>" /></a>
I don't know if it is best practice, but typically when I need an image to be a link in MVC, I do the following:
<%= Html.ActionLink("[replacethis]", myRouteStuff).Replace("[replacethis]", "<img src=""/images/myImage.jpg""/>" %>
I guess I have been too lazy to write a proper HTML Helper, but it works rather well and still maintains a rather clean look </subjective>
.
精彩评论