Reputation: 28296
@Html.ActionLink("Edit Me", "Edit", new { id=item.ID })
In the above example, how do I make "Edit Me" bold? I tried placing <b></b>
around the text but the bold tags are displayed literally. Instead of "Edit Me", the link displays "<b>
Edit Me</b>
".
Thanks!
PS - I'm using the MVC 4 beta but I don't see a tag that is that specific.
Upvotes: 2
Views: 16988
Reputation: 660
The easiest way is using the style attribute like:
@Html.ActionLink("Edit Me", "Edit", new { id=item.ID, style="font-weight:bold;" })
or you can set a class which you define in your css to be bold
@Html.ActionLink("Edit Me", "Edit", new { id=item.ID, @class="yourBoldClass" })
CSS: .yourBoldClass { font-weight: bold; }
Upvotes: 6
Reputation: 764
You can just put your url between <b></b> like that:
<b> @Html.ActionLink("Edit Me", "Edit", new { id=item.ID }) </b>
but the version with css is better
Upvotes: 3
Reputation: 218722
I dont usually apply styles to an ACtionLink method because i think it is not a clean approach. Instead i will use a css class and define my style there and use that it in my link like this
@Html.ActionLink("Edit Me", "Edit","yourControllerName", new { id=item.ID },new {@class="yourClassName"})
and have a css class like this
.yourClassName
{
font-weight:bold;
}
you are using this constructor here
public static MvcHtmlString ActionLink(
this HtmlHelper htmlHelper,
string linkText,
string actionName,
string controllerName,
Object routeValues,
Object htmlAttributes
)
Here is the documentation : http://msdn.microsoft.com/en-us/library/dd504972.aspx
Upvotes: 3
Reputation: 139758
You cannot insert html in the link text with Html.ActionLink
.
Write the <a>
"by hand" (or create a new helper):
<a href="@Url.Action("Edit", new { id=item.ID })"><b>"Edit Me"</b></a>
Or add a class to the link and do the "bolding" with CSS.
Upvotes: 1