Display text coming from the database query in @ Html.Actionlink ()

2

Well, I have the following scenario:

I query the database and I bring a IEnumerable<> to View :

 <section class="container">
    <article class="row">
        @foreach (var item in Model)
        {
            <div class="col-md-4">
                <div class="thumbnail">
                    <h3 style="background-color:orangered; margin:0; text-align:center;color:white;">@Html.ActionLink(item.Titulo, "MostraPublicacao", "Publicacao", new { id = item.PublicacaoId })</h3>     
                    <img src="~/Uploads/Imagens/teste.jpg" class="col-md-12 " style="padding:0;" />
                    <div>
                        @Html.DisplayFor(model => item.Resumo);
                    </div>
                </div>
            </div>
        }
    </article>
</section>

So, my TITTULO is received by this line

@Html.DisplayFor(model => item.Resumo);

I need to display the text of the summary in a @Html.ActionLink() to be a link in order to redirect to another View , which will receive the ID of this Object as a parameter

An image to try to better illustrate the problem:

How do I solve this problem?

    
asked by anonymous 03.02.2017 / 03:52

1 answer

2

Instead of @Html.DisplayFor(model => item.Resumo) just change to something like:

@Html.ActionLin(item.resumo, "ACTION", "CONTROLLER", new{id = item.PUBLICACAOID})

In this way, the text will be the abstract, but the generated HTML will look something like:

<a href="/CONTROLLER/ACTION/ID"> @item.titulo </a>
    
03.02.2017 / 03:59