Home > DeveloperSection > Forums > asp.net mvc razor getting id with post
Hugh Jackman
Hugh Jackman

Total Post:52

Points:366
Posted on    November-26-2014 10:09 PM

 ASP.Net ASP.NET MVC  Mvc  Razor 
Ratings:


 1 Reply(s)
 739  View(s)
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>

}



Kamlakar Singh
Kamlakar Singh

Total Post:194

Points:1396
Posted on    November-27-2014 12:33 AM

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;

}


Don't want to miss updates? Please click the below button!

Follow MindStick