- Response.Redirect(ReplaceQueryParameterValue(Request.RawUrl, "all", "1"));
- private string ReplaceQueryStringValue(string url, string key, string value)
- {
- return url.Contains(key) ? Regex.Replace(url, @"([?&]" + key + ")=[^?&]+", "$1=" + value) : (url + (url.Contains("?") ? "&" : "?") + key + "=" + value);
- }
- private string ReplaceQueryParameterValue(string query, string name, string value)
- {
- string output;
- if (query.Contains(name + "="))
- {
- output = System.Text.RegularExpressions.Regex.Replace(query,
- @"(&|\?)" + name + @"=[0-9A-Za-z\+\!\*\(\)\'\-\$\,\.]+", @"$1" + name + "=" + value,
- System.Text.RegularExpressions.RegexOptions.IgnoreCase);
- }
- else
- output = query + (query.Contains("?") ? "&" : "?") + name + "=" + value;
- return output;
- }
Thursday, 8 July 2010
REPLACE QUERY PARAMETER VALUE
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment