views:

100

answers:

3

Hello all,

I have navigation and many link on my webproject from html action links. They are ugly with underline. I would like to insert some image with name or play with styles of action link. Is it possible? How to do that?

Thanks and take care, Ragims

+2  A: 

You could use css to remove the underlines or place a backgroundimage, otherwise you could also just create the link like so:

<a href="<%: Url.Action("Action", "Controller")%>"><img src="yourimg.jpg" /></a>
lmondria
iam using html.actionlink, and not url.action
Ragims
Yeah, i know, but with Html.ActionLink you can't add any other content to the link than plain text.
lmondria
A: 

Html.ActionLink and Url.Action return the same URL. The difference is that the first creates an HTML element while the second returns just the URL to that action.

Another option is to use Url.RouteUrl or Html.RouteLink to create a link based off your route (to an action) instead of directly to an action.

Ryan Peters
A: 

One solution is to create an HtmlHelper extension method for creating an image-specific action link. A detailed tutorial can be found here.

Steve Danner