About Me

My photo
a Dynamic and Energetic guy.....

Monday, February 21, 2011

Change the query string values in C#

// 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);

this.Request.QueryString.Remove("playermode");
this.Request.QueryString.Add("playermode", "editinitialselection");

// make collection readonly again
isreadonly.SetValue(this.Request.QueryString, true, null);

3 comments:

Painy James said...

Fucking save my life do0d!

Unknown said...

ummm ... I bow to you. You da man!
thanks for post ... very nice.

Unknown said...

Thanks for post....

My Masters