ASP MVC3 embeds html tag inside actionlink

I am new to ASP MVC3 and I am using Razor Engine.

My broplem is that I created the main navigation in the form

<nav> <ul> <li><a href=""><b>Link</b></a></li></ul></nav> 

So how can I do this with actionlink? I just need to insert the b tag inside the tag.

+7
source share
2 answers

Use @Url.Action() to get the href value instead of @Html.ActionLink

+9
source

Replace this:

 <a href=""><b>Link</b></a> 

FROM

 @Html.ActionLink("<b>Link</b>", "Action", "Controller") 

This can automatically encode <b></b> , so you can try:

 @Html.ActionLink(new MvcHtmlString("<b>Link</b>").ToHtmlString(), "Action", "Controller") 

Even simpler, you can use @Url.Action("Action", "Controller") in a link, for example:

 <a href='@(Url.Action("Action", "Controller"))'><b>Link</b></a> 
+15
source

All Articles