'Can I use an HTML helper as a parameter inside another HTML helper in Asp.net?

I'm a new developer and need help with CSHTML formatting in Asp.net.

I use a helper method called @Html.Raw() that removes the Html tags from a string. So @Html.Raw(Model.ButtonText) returns the text without the tags. Without it, it returns <p>ButtonText</p>. (The tag comes from user input forms allowing users to format their input.)

I need this raw text as a label within an ActionLink helper method.

So...

<div>
@Html.ActionLink((@Html.Raw(Model.ButtonText)), Model.ButtonAction, "Auth", null, new { @class = "actionLink" })
</div>

When I do that, I get CS1929 error on my @Html.ActionLink.

I've tried creating a variable within the div and setting it to @Html.Raw(Model.ButtonText) and then using the variable as a parameter in the ActionLink, but it didn't work.

Any tips or work-arounds on this? Thank you!



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source