asp.net mvc - How to pass multiple parameter from view to controller in .Net MVC -
i need pass 2 parameters id , date view controller side on click event. may basic question not able so.
i tried code
code <a href='/abc/details/id?=@website_id, date?=@date' class="" id="prev" >prev</a>
and how parameter @ controller side.
i don't want use "ajax" or javascript if possible
first of either need create custom route or enable mapmvcattributeroutes in routeconfig file adding below line of code.
routes.mapmvcattributeroutes();
then in controller above defined action add below.
[route("/abc/details/{id}/{date}")]
if want make nullable then.
[route("/abc/details/{id?}/{date?}")]
your action method below.
[route("/abc/details/{id?}/{date?}")] public actionresult details(int id, string date)
use @html.actionlink instead of hard coding links.
if wanted go custom route add above default route.
routes.maproute( "mycustomroute", "archive/{entrydate}", new { controller = "abc", action = "details",id = urlparameter.optional,date = urlparameter.optional});
now in view
@html.routelink("link text", "mycustomroute", new { id = yourid, date=yourdate})
Comments
Post a Comment