Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

mvc3 Html.ActionLink as image not as text

<div class="orderby_name">
@Html.ActionLink(" ", "DisplayCategory", "Categories", new { articleSortBy = "Name", articleSortType = "asc" }, null)
</div>

i am lookin in razor if exist ImageLink. Now i have @Html.ActionLink and becouse i do not have any text name i can not click on it. I want to have image as link.

How can i make image as link in razor?

like image 571
senzacionale Avatar asked Dec 08 '11 19:12

senzacionale


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.

How do I transfer my ActionLink model to my controller?

ActionLink is rendered as an HTML Anchor Tag (HyperLink) and hence it produces a GET request to the Controller's Action method which cannot be used to send Model data (object). Hence in order to pass (send) Model data (object) from View to Controller using @Html.


2 Answers

The built-in helper cannot do that.

You need to create an ordinary <a href="@Url.Action(...)"> tag.

like image 74
SLaks Avatar answered Sep 24 '22 20:09

SLaks


Hope this code is helpful

@using (Html.BeginForm())
                {
                    <a href='@Url.Action("Index")'>
                        <img src='@Url.Content("../../Content/Images/head.jpg")' alt="Home Page">
                    </a>        }
like image 36
Saroop Trivedi Avatar answered Sep 26 '22 20:09

Saroop Trivedi