So today I wanted to have an image that redirected the user to one of my actions on a controller upon clicking it. Just like an 'a' tag wrapped around an image.
Up until now I've been merely using links, or more specifically the Html.ActionLink method to generate my links.

After a quick search I found this method which is very straight forward:

The Url.Action() view helper method. This method generates a 'raw' url given the appropriate parameters.

Syntax (for one of its 8 overloaded methods):

Url.Action(string actionName, string controllerName);


<a href='<%= Url.Action("Index","Home") %>'> <img src="image source here" /></a>

So using it to generate the raw url, pumping this url into an 'a' tag then wrapping the 'a' tag around an image achieved my goal.


Global ASP.NET Hosting Leader - Click Here

Add comment

  Country flag

  • Comment
  • Preview

Global ASP.NET Hosting Leader - Click Here