Last post Jun 28, 2013 04:54 AM by wally75
May 16, 2013 02:39 PM|xcentrik05|LINK
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)
May 16, 2013 02:47 PM|MetalAsp.Net|LINK
Use UrlEncode() on it.
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() ??
May 16, 2013 03:26 PM|smirnov|LINK
& works as a separator between key-value pairs
so, if you company will be AT&T then you should encode & as %26
So, either use simple string.Replace("&", "%26") for every value, or use special method UrlEncode
MyURL = "http://www.contoso.com/page.aspx?company=" + Server.UrlEncode("AT&T");
Hope this helps.
May 16, 2013 03:47 PM|xcentrik05|LINK
That worked! Thank You for the help!
Jun 27, 2013 01:27 PM|wally75|LINK
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:
or if I've a url like this:
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.
thanks in advance!
P.S. - Sorry for my english! :(
Jun 27, 2013 02:07 PM|smirnov|LINK
Request.QueryString["companyName"] should return what you want.
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! :)