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.

share|improve this question

1 Answer

up vote 4 down vote accepted

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));
%>
share|improve this answer

Your Answer

 
or
required, but never shown
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.