ASP.NET MVC passing an ID in an ActionLink to the controller

前端 未结 5 1719
故里飘歌
故里飘歌 2020-12-07 20:03

I can\'t see to retrieve an ID I\'m sending in a html.ActionLink in my controller, here is what I\'m trying to do

  • <%= Html.ActionLink(\"Mod
  • 5条回答
    •  时光取名叫无心
      2020-12-07 20:08

      Doesn't look like you are using the correct overload of ActionLink. Try this:-

      <%=Html.ActionLink("Modify Villa", "Modify", new {id = "1"})%>
      

      This assumes your view is under the /Views/Villa folder. If not then I suspect you need:-

      <%=Html.ActionLink("Modify Villa", "Modify", "Villa", new {id = "1"}, null)%>
      

    提交回复
    热议问题