using System.Reflection;
using System.Collections.Specialized;
+++++++++++++++++++++++++++++++++++++++++++++++++++
//Modify the query string at run time
string path = HttpContext.Current.Request.Url.AbsoluteUri;
string[] strarr = path.Split('?');
if (strarr.Length > 1)
{
if (strarr[1].Contains("JobType"))
{
// reflect to readonly property
PropertyInfo isreadonly =
typeof(System.Collections.Specialized.NameValueCollection).
GetProperty("IsReadOnly", BindingFlags.Instance |
BindingFlags.NonPublic);
// make collection editable
isreadonly.SetValue(this.Request.QueryString, false, null);
// modify
this.Request.QueryString.Set("JobType",
Convert.ToString(e.CommandName));
// make collection readonly again
isreadonly.SetValue(this.Request.QueryString, true, null);
Response.Redirect(strarr[0] + "?" +
this.Request.QueryString, false);
}
else
{
Response.Redirect(path + "&JobType=" +
Convert.ToString(e.CommandName), false);
}
}
else
{
Response.Redirect(path + "?JobType=" +
Convert.ToString(e.CommandName), false);
}
0 comments:
Post a Comment