Getting source with @ Html.ActionLink in Razor / MVC3?

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 header field. However, I cannot display values ​​encoded in HTML. i.e. Underlined text is displayed with <u>....</u>around it.

I tried Html.Raw in the text part of ActionLink but did not go.

Any suggestions?

+5
source share
5 answers

HTML , , Html.ActionLink. , fooobar.com/questions/656225/... , .

HTML Url.Action, URL-, Html.ActionLink :

<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>
+13

MVCHtmlString.Create .

0

actionlink , html . css href.

@Html.ActionLink(Model.dsResults.Tables[0].Rows[i]["title"], "ItemLinkClick", "Controller", new { @class = "underline", style="text-decoration: underline" }, null)
0

,

@{
    string title = Model.dsResults.Tables[0].Rows[i]["title"].ToString(),
           aHref = String.Format("/ItemLinkClick/itemListID={0}&itemPosNum={1}...", 
                       Model.dsResults.Tables[0].Rows[i]["ItemListID"],
                       i+1);
}

<a href="@aHref" class="whatever">@Html.Raw(title)</a>

, Razor , - HTML-.

0

:

<a class='btn btn-link' 
   href='/Mycontroler/MyAction/" + item.ID + "'
   data-ajax='true' 
   data-ajax-method='Get' 
   data-ajax-mode='InsertionMode.Replace' 
   data-ajax-update='#Mymodal'>My Comments</a>
0

All Articles