send id from view to controller
I have a view that receives a Model and displays info of that model. I have a submit button and when it is clicked i w开发者_StackOverflow社区ant it to send the id to the method to process it and delete a row that has such id.
How can I do this? I want to use a button
not an html link like
@Html.ActionLink("Delete", "Delete", new { id = Model.Id }) |
Thanks!
I tried input type hidden but hasn't worked =(
You can use a form to do this... I don't use razor, but an equivalent .aspx way to do this would be:
<%using (Html.BeginForm("Home", "myaction", new { Id = 1 }))
{ %>
<input type="submit" value="submit" />
<%} %>
This will post to ~/Home/myaction/1
Just call Html.BeginForm with the appropriate razor syntax.
精彩评论