C#C
C#2y ago
Gipper

How to pass variable from one View to another View in link?

Ok, so I have this code in my view:
@foreach (var item in Model)
{
    @if(Model.Any(utilizadorGrupo=>utilizadorGrupo.UtilizadorId == userID))
    {
        @if (userID == item.UtilizadorId)
        {

            <a id="nomeGrupo" href="@Url.Action("verPublicacaoGrupo")?nomeGrupo=@item.Grupo.Nome_grupo"><strong>@item.Grupo.Nome_grupo</strong></a>
        }
    }
}

as you can see, in this view I am including a link to another view, I loop through a collection of objects and would like to pass the value of one of the fields of that object (Nome_grupo) to the view being linked to. I am doing it in the Razor syntax way because it seemed simpler, but I am open to any other way as this one has proved a bit wonky.
Was this page helpful?