c# - How to create an ActionLink that retains the parameters from the request? -
i have view responding action /page/index/{id}
(default asp.net mvc routing). view contains action links lead same action same id
added parameter in url. i've put in place:
@html.actionlink("setvar1", "index", new { var1 = "true" } ) @html.actionlink("setvar2", "index", new { var2 = "true" } )
as expected, clicking on 1 of links redirects me same action same id
, parameter.
page/index/{id}?var1=true
the user presented above links again. of course, if user clicks again on action link, new parameter there.
page/index/{id}?var2=true
what want instead make action links retain passed parameters , add new one (or replace if has value in request).
page/index/{id}?var1=true&var2=true
how can that?
it crucial don't hardcode possible parameter names , i'd find inelegant string manipulation url directly. should note parameters independent of each other.
there several techniques doing this, however, none of them automatic, still have tell actionlink explicitly want inside actionlink.
there few questions on stackoverflow describe same or similar problem check out:
Comments
Post a Comment