Given the following Html.ActionLink:
@Html.ActionLink(Model.dsResults.Tables[0].Rows[i]["title"].ToString(), "ItemLinkClick",
new { itemListID = @Model.dsResults.Tables[0].Rows[i]["ItemListID"], itemPosNum = i+1 }, ...
Data from the model contains HTML in the title field. However, I am unable to display the HTML encoded values. ie. underlined text shows up with the <u>....</u>
around it.
I've tried Html.Raw in the text part of the ActionLink, but no go.
Any suggestions?
Html. ActionLink creates a hyperlink on a view page and the user clicks it to navigate to a new URL. It does not link to a view directly, rather it links to a controller's action.
Yes, there is a difference. Html. ActionLink generates an <a href=".."></a> tag whereas Url. Action returns only an url.
Raw allows you to output text containing html elements to the client, and have them still be rendered as such. Should be used with caution, as it exposes you to cross site scripting vulnerabilities.
@Html. ActionLink("name", "Action", "Controler", new { id= sentId, Style = "color:White" }, null);
If you still want to use a helper to create an action link with raw HTML for the link text then I don't believe you can use Html.ActionLink
. However, the answer to this stackoverflow question describes creating a helper which does this.
I would write the link HTML manually though and use the Url.Action
helper which creates the URL which Html.ActionLink
would have created:
<a href="@Url.Action("ItemLinkClick", new { itemListID = @Model.dsResults.Tables[0].Rows[i]["ItemListID"], itemPosNum = i+1 })">
@Html.Raw(Model.dsResults.Tables[0].Rows[i]["title"].ToString())
</a>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With