Tripping
Tripping

Reputation: 919

html code in anchor tag text in c# razor

I am trying to show the rupee sign: ₹ code: &#8377 ; in my anchor tag.

I have tried a few things but nothing works ... please help

        @{ string _text =
               String.Format("{0} {1} {2} {3} {4}",
               @Html.DisplayFor(model => model.NoOfBedrooms),
               "bedroom flat",
               @Html.DisplayFor(model => model.TransactionTypeDescription),
               @Html.Raw(₹),
               @Html.DisplayFor(model => model.Price));

           string _rental = "";
           if (Model.TransactionType == 2) { _rental = " per month"; } else { _rental = ""; };

           string _linkText = _text + _rental;
        }



@Html.ActionLink(_linkText, "Details", "Property", new { id = Model.PropertyId }, null)

Upvotes: 1

Views: 3356

Answers (1)

McGarnagle
McGarnagle

Reputation: 102753

I'm not sure you can do it with Html.ActionLink, but you can always construct it manually by using <a href='@Url.Action("Index")'>@Html.Raw("&#8377")</a>.


@{ string _text =
           String.Format("{0} {1} {2} {3} {4}",
           @Html.DisplayFor(model => model.NoOfBedrooms),
           "bedroom flat",
           @Html.DisplayFor(model => model.TransactionTypeDescription),
           "&#8377;",
           @Html.DisplayFor(model => model.Price));

       string _rental = "";
       if (Model.TransactionType == 2) { _rental = " per month"; } else { _rental = ""; };

       string _linkText = _text + _rental;
    }

<a href='@Url.Action("Details", "Property", new { id = Model.PropertyId })'>
    @Html.Raw(_linkText)
</a>

Upvotes: 1

Related Questions