Jami
Jami

Reputation: 589

How can I include markup as linktext in an anchor<a> in MVC?

Using Razor I have a page I want to put an anchor whose linktext includes markup. for example:

<a href="some url"> <div>Line1<div> </a>

I tried the following code:

@Html.ActionLink(@Html.Raw("<div>") + "Create New" + @Html.Raw("</div>"), "Create")

but it didn't work.

I know that this might look a bit odd. But is it possible to do that in MVC?

Upvotes: 0

Views: 85

Answers (1)

Yogesh
Yogesh

Reputation: 2228

No, it's not possible. However, you can create a new HTML helper method for this. It should be pretty straight forward to do so. If not you can use URL.Action link.

<a href="@Url.Action("Action", "Controller")">
    <div> Create New </div>
</a>

Upvotes: 4

Related Questions