In a creation (or edit) form I use helpers and partials to display either a DropDownBox or a summary for categories, vendors or whatever other model the object refers to.
Example: Products/Create?category_id=1&vendor_id=1
shows a summary for Category and one for Vendor, while Products/Create?category_id=1
shows a summary for Category and a DropDownBox for Vendor.
I want to add to the Summary partials a link to the same url less one parameter: the Category Summary partial should link to same URL less category_id
, the Vendor one to same URL less vendor_id
.
To decide wether to display the link I use:
private static bool IsChangeableAction(RouteData routeData)
{
String action = (String) routeData.Values["action"];
return (action == "Create") || (action == "Edit");
}
To create the link I plan to use some overloads, each accepting a different model, so that I can use the same helper everywhere.
I was unable to find a way to get url parameters: RouteData.Values
only contains Route values, while HttpContext.Request.Params
contains tons of parameters. What's the right way?
Also, is there anything wrong in what I'm trying to do - and how I'm trying to do it?