how to get an id of a model in a view through a link?

1

I have a link that calls a function JS (POPUP), in this popup I have a registration form, to validate all the parameters of my form, I need to obtain the ID of the My Model that is in the view of the Link I am not able to obtain this ID for insertion of data in BD

Take a look at my cod:

view:

<table>
<tr>
    <th>Nome</th>
    <th>Adicionar</th>
</tr>
@foreach (var c in Model.Contactados)
{
 <tr>
   <td>@Html.DisplayFor(cc => c.Nome)</td>
     <td><a class ="chamar" href="#">Adicionar</a></td>        
 </tr>
}

form that should receive the ID of the previous view:

   @using Forte.Rastreador.ViewModels
@model SuperViewModel
@using (Html.BeginForm("CadastrarContatoContactado", "Master", FormMethod.Post))
{

@Html.ValidationSummary(false)

<fieldset>
<legend></legend>
@Html.Label("Contato: ")
@Html.TextBoxFor(c=>c.DescricaoContatoContactado)
@Html.Label("Tipo Contato: ")
@Html.DropDownListFor(c => c.CodTipoContato, Model.TipoContatoList)

<input type="submit" value="Adicionar Contato" />

}
    
asked by anonymous 23.12.2014 / 14:31

1 answer

1

Use @Html.HiddenFor(c=>c.Id) within the Form. So it will be sent to the Controller.

    
30.12.2014 / 15:03