ASP.NET MVC RAZOR GETTING ID WITH POST

Hugh Jackman

Total Post:52

Points:366
Posted by  Hugh Jackman
 1055  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. Kamlakar Singh

    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;

    }

Answer

NEWSLETTER

Enter your email address here always to be updated. We promise not to spam!