asp.net mvc razor getting id with post

Total Post:51

Points:359
 1458  View(s)
Ratings:
Rate this:

how can i get the querystring id in there? is there any way 

@using (Html.BeginForm("InformVendor", "Procurement",new {id="querystring Mode = "Inform" }, FormMethod.Post))
{
<tr>
    <td>
          @Html.DropDownListFor(m=>m.VendorId,new MultiSelectList(Model.VendorDropdownlist, "CustomerId", "ContactName"))  
     </td>
    <td>
          @Html.CheckBoxFor(m => m.IsEmail)
   </td>       
</tr>
<tr>
    <td>
         <input type="submit" id="btnsubmit" value="Nominate Vendor" />
    </td>
    <td></td>
</tr>
}

  1. Post:194

    Points:1396
    Re: asp.net mvc razor getting id with post

    If you add the Id to your view model and render it as a hidden field.

    @Html.HiddenFor(m => m.Id)

    You will be able to retrieve it like this instead of using the querystring.

    public ActionResult InformVendor(AViewModel model)
    {
       var Id = model.Id;
    }

      Modified On Apr-07-2018 01:07:09 AM

Answer