468,719 Members | 1,810 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,719 developers. It's quick & easy.

"&" symbol in querystring

I have a problem if the parameter has a "&" symbol in querystring,

i think asp.net will split the value into 2 values as "&" is a spliter

any advise can give me to solve this problem?

P.S. I can't restrict user don't input "&" symbol when input

Thanks in advanced.
Feb 10 '06 #1
2 2364
Yes, you need to use Server.UrlEncode.
This will turn the ampersand into an encoded character.
Then, when you read in the querystring, make sure you use
Server.UrlDecode.

Note: dont be confused with Server.HtmlEncode which is used for
encoding HTML tags.
So here's an example:

string url = "result.aspx?text=" + Server.UrlEncode(InputBox.Text)

and on other end

string result = Server.UrlDecode(Request.Querystring["text"])

Feb 10 '06 #2
beachboy wrote:
I have a problem if the parameter has a "&" symbol in querystring,


Replace the & with %26.
--
Truth,
James Curran [erstwhile-MVP]
Home: www.noveltheory.com Work: www.njtheater.com
Blog: www.honestillusion.com Day Job: www.partsearch.com
Feb 10 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by Arpan | last post: by
6 posts views Thread by vigi98 | last post: by
4 posts views Thread by barney | last post: by
5 posts views Thread by martin | last post: by
2 posts views Thread by Mehdi | last post: by
5 posts views Thread by chortler | last post: by
3 posts views Thread by beachboy | last post: by
1 post views Thread by EoRaptor013 | last post: by
4 posts views Thread by Winks | last post: by
1 post views Thread by CARIGAR | last post: by
1 post views Thread by Oskars | last post: by
9 posts views Thread by bryonone | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.