I'm very new to VB so please understand I only partially understand what I'm looking at.
I am taking user entered data and passing it through a query string to another page. the data will be used in another query that will eventually display on another page. When a user types an ampersand (&) the Request.QueryString does not recognize anything
after the ampersand (&). Can someone tell me if there is a work around? Should i be using something else?
Sorry, but can you explain a little further. Where do i put UrlEncode() ? Im using Visual Studio and Intellisense doesn't recognize. It recognizes HttpServerUtilit.UrlTokenEncode() ??
in both cases, when I try to get the companyName parameter, I obtain the AT string and not the AT&T, because both & and %26 delimit my companyName parameter.
Thank you for the quick answer! I had the error also doing as you suggest me, but in really the cause was stupid distraction issue! :(
So it was only my fault!
The page I debugged was inside a frame, but in my application all the calls are handled before by the top page that forwards the parameter to the inner page, so the external page gets the correct parameter (using %26) but when it forwards the parameter to
the inner page it was been automatically decoded and forwarded as "&" and not as "%26".
I solved re-encoding all of the parameters in forwarding method.
Member
1 Points
6 Posts
QueryString Ampersand
May 16, 2013 02:39 PM|xcentrik05|LINK
Hi All,
I'm very new to VB so please understand I only partially understand what I'm looking at.
I am taking user entered data and passing it through a query string to another page. the data will be used in another query that will eventually display on another page. When a user types an ampersand (&) the Request.QueryString does not recognize anything after the ampersand (&). Can someone tell me if there is a work around? Should i be using something else?
my code looks like the below
OrgName = Request.QueryString(OrgName)
All-Star
101931 Points
20703 Posts
Re: QueryString Ampersand
May 16, 2013 02:47 PM|MetalAsp.Net|LINK
Use UrlEncode() on it.
Member
1 Points
6 Posts
Re: QueryString Ampersand
May 16, 2013 03:09 PM|xcentrik05|LINK
Sorry, but can you explain a little further. Where do i put UrlEncode() ? Im using Visual Studio and Intellisense doesn't recognize. It recognizes HttpServerUtilit.UrlTokenEncode() ??
All-Star
35149 Points
9075 Posts
Re: QueryString Ampersand
May 16, 2013 03:26 PM|smirnov|LINK
& works as a separator between key-value pairs
?company=Verizon&date=010113
so, if you company will be AT&T then you should encode & as %26
?company=AT%26T&date=010113
So, either use simple string.Replace("&", "%26") for every value, or use special method UrlEncode
http://msdn.microsoft.com/de-de/library/vstudio/zttxte6w.aspx
Hope this helps.
Member
1 Points
6 Posts
Re: QueryString Ampersand
May 16, 2013 03:47 PM|xcentrik05|LINK
That worked! Thank You for the help!
None
0 Points
2 Posts
Re: QueryString Ampersand
Jun 27, 2013 01:27 PM|wally75|LINK
Hi,
I've the same problem, but if I replace the & with %26, I keep have the same error...
If I've a url like this:
http://localhost/?pageId=33&companyName=AT&T®Num=45
or if I've a url like this:
http://localhost/?pageId=33&companyName=AT%26T®Num=45
in both cases, when I try to get the companyName parameter, I obtain the AT string and not the AT&T, because both & and %26 delimit my companyName parameter.
Why?
thanks in advance!
P.S. - Sorry for my english! :(
All-Star
35149 Points
9075 Posts
Re: QueryString Ampersand
Jun 27, 2013 02:07 PM|smirnov|LINK
Use
http://localhost/?pageId=33&companyName=AT%26T®Num=45
and then
Request.QueryString["companyName"] should return what you want.
None
0 Points
2 Posts
Re: QueryString Ampersand
Jun 28, 2013 04:54 AM|wally75|LINK
Thank you for the quick answer! I had the error also doing as you suggest me, but in really the cause was stupid distraction issue! :(
So it was only my fault!
The page I debugged was inside a frame, but in my application all the calls are handled before by the top page that forwards the parameter to the inner page, so the external page gets the correct parameter (using %26) but when it forwards the parameter to the inner page it was been automatically decoded and forwarded as "&" and not as "%26".
I solved re-encoding all of the parameters in forwarding method.
Thank you for the attention spent to me! :)