How to pass query string parameter in ActionLink in MVC

后端 未结 4 586
悲&欢浪女
悲&欢浪女 2021-02-03 16:52

I am having following action link:

<%= Html.ActionLink(\"Check this\", \"Edit\", \"test\", 
                     new { id = id }, new { style = \"display:bloc         


        
4条回答
  •  梦如初夏
    2021-02-03 17:33

    Pass Query String By this way

    @Html.ActionLink("Delete Record", "Home", "Delete", new { id=Id},null)
    

    By above code you will get the url like(Suppose Id=1): /Home/Delete/1

    and if you want to add more parameters to query string then:

    @Html.ActionLink("Delete Record", "Home", "Delete", new { id=Id, Name=name},null)
    

    By above code you will get the url like(Suppose Id=1 and Name=India) :

    /Home/Delete/1?Name=India
    

提交回复
热议问题