Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to insert image in html action link? asp.net mvc

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

like image 588
r.r Avatar asked Sep 02 '10 12:09

r.r


People also ask

What is HTML ActionLink ()?

ActionLink(HtmlHelper, String, String, String, String, String, String, Object, Object) Returns an anchor element (a element) for the specified link text, action, controller, protocol, host name, URL fragment, route values, and HTML attributes.

What is difference between HTML ActionLink and URL action?

There is a difference. Html. ActionLink generates an <a href=".."></a> tag whereas Url. Action returns only an url.


2 Answers

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>
like image 65
lmondria Avatar answered Nov 05 '22 18:11

lmondria


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.

like image 42
Ryan Peters Avatar answered Nov 05 '22 17:11

Ryan Peters