Wrox Home  
Search P2P Archive for: Go

  Return to Index  

asp_databases thread: Replacing ampersand in querystring


Message #1 by imran.saleem@b... on Wed, 30 Oct 2002 14:21:02
Hi,
   please could you tell me what i need to replace an ampersand(&) with 
when it occurs in a querystring. I know this thread has been answered 
before but the answers seem a little muddles. One person is suggesting one 
thing another is suggesting another.

Thanks in advance for your help.   
Message #2 by "Peter Foti (PeterF)" <PeterF@S...> on Wed, 30 Oct 2002 10:22:57 -0500
If you are creating a query string in a link, and you want to include the
ampersand, you should do this:

<%
Response.Write("<a href=""www.mysite.com/index.asp?var1=" &
Server.URLEncode("AT&T") & """>click here</a>")
%>

Server.URLEncode will properly encode the ampersand (and any other values
that need encoding in the querystring).  For the ampersand, the encoded
value is:
%26

Also, note that if you have more than 1 item in the query string, you must
do Server.URLEncode on each one.  Otherwise, the ampersand that separates
them will be encoded when it shouldn't be.

Hope this helps.
Regards,
Peter


-----Original Message-----
From: imran.saleem@b... [mailto:imran.saleem@b...]
Sent: Wednesday, October 30, 2002 2:21 PM
To: ASP Databases
Subject: [asp_databases] Replacing ampersand in querystring


Hi,
   please could you tell me what i need to replace an ampersand(&) with 
when it occurs in a querystring. I know this thread has been answered 
before but the answers seem a little muddles. One person is 
suggesting one 
thing another is suggesting another.

Thanks in advance for your help.   
Message #3 by imran.saleem@b... on Wed, 30 Oct 2002 15:24:11 -0000
Thanks for all the help, used the server.URLEncode hint and it worked fine.

-----Original Message-----
From: Peter Foti (PeterF) [mailto:PeterF@S...]
Sent: Wednesday, October 30, 2002 3:23 PM
To: ASP Databases
Subject: [asp_databases] RE: Replacing ampersand in querystring


If you are creating a query string in a link, and you want to include the
ampersand, you should do this:

<%
Response.Write("<a href=""www.mysite.com/index.asp?var1=" &
Server.URLEncode("AT&T") & """>click here</a>")
%>

Server.URLEncode will properly encode the ampersand (and any other values
that need encoding in the querystring).  For the ampersand, the encoded
value is:
%26

Also, note that if you have more than 1 item in the query string, you must
do Server.URLEncode on each one.  Otherwise, the ampersand that separates
them will be encoded when it shouldn't be.

Hope this helps.
Regards,
Peter


-----Original Message-----
From: imran.saleem@b... [mailto:imran.saleem@b...]
Sent: Wednesday, October 30, 2002 2:21 PM
To: ASP Databases
Subject: [asp_databases] Replacing ampersand in querystring


Hi,
   please could you tell me what i need to replace an ampersand(&) with 
when it occurs in a querystring. I know this thread has been answered 
before but the answers seem a little muddles. One person is 
suggesting one 
thing another is suggesting another.

Thanks in advance for your help.   


  Return to Index