I’m implementing a custom control and in this control I need to write a bunch of links to the current page, each one with a different query parameter. I need to keep existing query string intact, and add (or modify the value of ) an extra query item (eg. ‘page’):
'Default.aspx?page=1' 'Default.aspx?page=2' 'Default.aspx?someother=true&page=2'
etc.
Is there a simple helper method that I can use in the Render method … uhmm … like:
Page.ClientScript.SomeURLBuilderMethodHere(this,'page','1'); Page.ClientScript.SomeURLBuilderMethodHere(this,'page','2');
That will take care of generating a correct URL, maintain existing query string items and not create duplicates eg. page=1&page=2&page=3?
Rolling up my own seems like such an unappealing task.
I’m afraid I don’t know of any built-in method for this, we use this method that takes the querystring and sets parameters
Obviously you could use the QueryString
NameValueCollectionproperty of the URI object to make looking up the values easier, but we wanted to be able to parse any querystring.