Reputation: 1
I am facing one problem while storing a querystring value in a variable. My url is something like shown below:
http://localhost:1372/testapp/default.aspx?Search=%family%
Below is what I tried:
string result = Request.QueryString["Search"].ToString();
When I tried to save the querystring search in variable its taking value as �mily%
.
How can I get value of search parameter as family?
Thanks in advance.
Upvotes: 0
Views: 479
Reputation: 2276
In Parent Page Encode query string this way
public static sting Encode(string sData)
{
return HttpUtility.UrlEncode(sData);
}
Now pass this encoded query string to your parent page & on Parent page decode that query string by following function. I assume that encoded query string name is sData & its passed from parent page to child page
public static string Decode()
{
string dSData = HttpUtility.UrlDecode(Request.QueryString["sData"].ToString());
return dsData;
}
I think you have idea about how to pass query string from parent to child page
try this solution for more .
Upvotes: 1
Reputation: 1685
The query string parameters have to get URL-encoded. The problem ist th % character which is used for URL encoding, so it has to get encoded itself.
'%' becomes '%25'
Which means, the whole URL becomes:
http://localhost:1372/testapp/default.aspx?Search=%25family%25
your can use HttpUtitlity.UrlEncode
Upvotes: 1