I have this menu:

<ul class="menu"> <li><a href="/"><span class="activ">пункт1</span></a></li> <li><a href="/"><span>пункт2</span></a></li> </ul> 

You need to use @Html .ActionLink, so I can write

  <ul class="menu"> <li><a href="/"><span class="@ViewBag.ClassActive">пункт1</span></a></li> <li> @Html .ActionLink("Пункт1", ....)</li> </ul> 

how do i line "item1" wrap in <span class = "@ ViewBag.ClassActive"> item1 </ span>?

otherwise it is displayed as plain text. I wanted to use Html.Raw and new HtmlString, but the type does not fit

type conversion from "System.Web.IHtmlString" to "string" is not possible

    1 answer 1

    In addition to @Html .ActionLink, which generates markup of the type <a href="/....">пункт2</a> , there is a method @ Url.Action that generates only a link. Those. Your task can be solved like this:

     <li><a href="@Url.Action("Пункт1", ....)"><span>пункт2</span></a></li>