Span within @ Html.ActionLink

3

I have the following column of a table:

<td style="font-size:10%">
   <p class="list-group-item-text">
      @Html.ActionLink((string)item.cidadenome, "Cidade", "Cidade", new { cidadecod = item.cidadecod, contratocod = item.contratocod }, new { @class = "list-group-item active", @style = "font-size: 18px" } )
      <span class="badge" style="font-size: 12px; background-color:@item.statusservidor_stts">
          @item.statusservidor
      </span>
    </p>
</td>

However, the content of the Span is displayed below ActionLink, as shown in the image below:

I would like the Span to be displayed in the Action Link (in the blue part) after the number. What should I do?

    
asked by anonymous 08.09.2016 / 21:25

2 answers

3

Use @Url.Action instead of @Html.ActionLink :

<td style="font-size:10%">
   <p class="list-group-item-text">
      <a href="@Url.Action("Cidade", "Cidade", new { cidadecod = item.cidadecod, contratocod = item.contratocod })" class = "list-group-item active", style = "font-size: 18px">
          @item.cidadenome
          <span class="badge" style="font-size: 12px; background-color:@item.statusservidor_stts">
              @item.statusservidor
          </span>
      </a>
   </p>
</td>
    
08.09.2016 / 21:31
1

Use @Url.Action it mounts the URL to you dynamically with the passed parameters.

I prefer to create link using @Url.Action than @Url.ActionLink because it visually gets easier for someone who does not know Razor HELPERS understands that there is a link and @Url.Action returns a URL

    
08.09.2016 / 22:05