Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

append a parameter to querystring of existing url asp.net mvc

Tags:

c#

asp.net-mvc

Im using asp.net mvc. c#

How can i get the existing url (may have a bunch of querystring parameters on it) and then just append another parameter to the quesrystring. and make this a clickable hyperlink.

like image 629
raklos Avatar asked Feb 01 '10 23:02

raklos


1 Answers

You're going to need to build a custom RouteValueDictionary variable to pass to Html.ActionLink. Try something like this:

<% 
     var rvd = new RouteValueDictionary(ViewContext.RouteData.Values);
     foreach (string key in Request.QueryString.Keys )
     {
         rvd[key]=Request.QueryString[key];
     } 
     rvd["MyParam"] = "WhateverValue";
     Response.Write(Html.ActionLink("Link Text", "Action", rvd));
%>
like image 96
womp Avatar answered Sep 27 '22 17:09

womp