Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Add a line break for a long link title within Html.ActionLink MVC2

I have a long title and need to add something like a line break within the ActionLink. I've tried \r\n as well as System.Environment.NewLine...all with no success.

<%=Html.ActionLink("Long title goes here", "index", "Overview")%>
like image 904
Tre Avatar asked Dec 17 '10 17:12

Tre


People also ask

What is HTML ActionLink ()?

ActionLink(HtmlHelper, String, String) Returns an anchor element (a element) for the specified link text and action. ActionLink(HtmlHelper, String, String, Object) Returns an anchor element (a element) for the specified link text, action, and route values.

What is difference between HTML ActionLink and URL action?

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

Which is the correct way to specify an anchor HyperLink in MVC view?

The Anchor Tag Helper generates HTML anchor (<a> </a>) element by adding a new attribute. The "href" attribute of the anchor tag is created by using new attributes. The Anchor Tag Helper generates an HTML anchor (<a> </a>) element by adding new attribute.

How do I pass an object in ActionLink?

If you need to pass through the reference to an object that is stored on the server, then try setting a parameter of the link to give a reference to the object stored on the server, that can then be retrieved by the action (example, the Id of the menuItem in question).


1 Answers

You may try something like this:

<a href="<%= Url.Action("index", "overview") %>">
    Long title first line<br/>
    Long title second line<br/>
    Long title third line
</a>
like image 165
Darin Dimitrov Avatar answered Sep 29 '22 18:09

Darin Dimitrov