pass query string parameter in ActionLink in MVC

Total Post:67


 7064  View(s)
Rate this:
I am having following action link:

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

How to include "data=name" as query string. Some thing like link?data=name
  1. Re: pass query string parameter in ActionLink in MVC

    4th parameter of Html.ActionLink can have any number od properties:

       <%= Html.ActionLink("Check this", "Edit", "test", 
        new { id = id, data=name }, new { style = "display:block" })%>

    Theese properties are inserted into URL based on routing, but if the property name cannot be matched into any route it is added as URL GET parameter. So if you have standard route "{controller}/{action}/{id}", you will get the URL test/Edit/[id]?data=[name] from the above code.

      Modified On Apr-06-2018 12:54:14 AM


Please check, If you want to make this post sponsored

You are not a Sponsored Member. Click Here to Subscribe the Membership.