Putting HTML inside Html.ActionLink(), plus No Link Text?
Instead of using Html.ActionLink you can render a url via Url.Action
<a href="<%= Url.Action("Index", "Home") %>"><span>Text</span></a>
<a href="@Url.Action("Index", "Home")"><span>Text</span></a>
And to do a blank url you could have
<a href="<%= Url.Action("Index", "Home") %>"></a>
<a href="@Url.Action("Index", "Home")"></a>
Using HTML tags inside linkText of Html.ActionLink
No; it's not possible.
You need to manually write an <a>
tag.
Html.ActionLink as a button or an image, not a link
Late response but you could just keep it simple and apply a CSS class to the htmlAttributes object.
<%= Html.ActionLink("Button Name", "Index", null, new { @class="classname" }) %>
and then create a class in your stylesheet
a.classname
{
background: url(../Images/image.gif) no-repeat top left;
display: block;
width: 150px;
height: 150px;
text-indent: -9999px; /* hides the link text */
}
Create an ActionLink with HTML elements in the link text
You could use Url.Action to build the link for you:
<a href="<% =Url.Action("Action", "Controller")%>">link text <span>with further blablah</span></a>
or use Html.BuildUrlFromExpression:
<a href="<% =Html.BuildUrlFromExpression<Controller>(c => c.Action()) %>">text <span>text</span></a>
ASP MVC3 insert html tag inside actionlink
Use @Url.Action()
to get href value instead of @Html.ActionLink
ActionLink italics certain portion
As far as Html.ActionLink()
just render <a href=".."></a>
tag maby that's not the best way to achive your goal.
I belive in your case it's better to use Url.Action()
helper like this:
<a href="@Url.Action("Vtd", "Crs", new { Text= Html.Encode("How it works"}, null })">
How do <i>This</i>
</a>
MVC3 - Razor: How to use html tag in ActionLink Name
Using the URL.Action
instead of an action link you have more control over the contents.
<a href="@Url.Action("Index", "Home")" class="button lines-6">
<strong>Click Here </strong> (I do not have Middle Name)
</a>
Related Topics
Implicit Conversion Issue in a Ternary Condition
.Net - Convert Generic Collection to Datatable
Wpf C#: Rearrange Items in Listbox via Drag and Drop
Winforms: Application.Exit VS Environment.Exit VS Form.Close
Visual Studio One Project with Several Dlls as Output
Number of Occurrences of a Character in a String
How to Retrieve the Loaderexception Property
Gmail Smtp via C# .Net Errors on All Ports
Routing with Multiple Get Methods in ASP.NET Web API
Getting All Changes Made to an Object in the Entity Framework
Converting Xml to a Dynamic C# Object
How to Execute an X86 Assembly Sequence from Within C#
Only Parameterless Constructors and Initializers Are Supported in Linq to Entities