471,109 Members | 1,435 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,109 software developers and data experts.

"&" 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 2427
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

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.