Friday, March 16, 2012

passing ampersand(&) in querystring

I am trying to send a clients name to another page through a querystring, but some of their names are being cut in half where there is an amp.
 server.urlencode(Container.DataItem("Username"))
I even tried to use
Server.HtmlEncode
on the front and
.replace("&","^")
on the end, but I can't get it to work.
Does anyone know how to do this?
ThanksYou need to not have the ampersand in the querything unless before the parameter name. If you were doing soemthing like first&last, either send them as two words, or put a unique character that you can do a string.replace(character, newchar)
Thanks for the reply.
The problem is when there is a & as part of their name, such asA&B Painters
Also, not all company names have more than one word in them.

I think I used string.replace(character, newchar) as above, however it did nothing. Did I use it right? I think that is the way to go if I can get it to work.
Thanks
Just to make sure we have this straight, you are doing something like thisbefore you post it to the querystring:

Dim StringVar As String = "A&B Painters"

StringVar.Replace("&", "^")
Cool!
I will try that.

0 comments:

Post a Comment