473,545 Members | 2,444 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

& in a QueryString

I am looping threw the querySting with:
foreach (string name in Request.QuerySt ring)

I have a problem with a '&' being in one of the values. How do I deal with
this?

page.asp?theVal =2&theVal2=aa& e overdue
--
David Fetrow
Helixpoint LLC.
http://www.helixpoint.com
da***@helixpoin t.com
Nov 18 '05 #1
4 1736
Hi Dave,
I think you should URLEncode the string before you build the hyperlink.
Basically "&" will create your ampersand ("&")

jt
"DaveF" <df*****@geodec isions.com> wrote in message
news:OX******** ******@TK2MSFTN GP10.phx.gbl...
I am looping threw the querySting with:
foreach (string name in Request.QuerySt ring)

I have a problem with a '&' being in one of the values. How do I deal with
this?

page.asp?theVal =2&theVal2=aa& e overdue
--
David Fetrow
Helixpoint LLC.
http://www.helixpoint.com
da***@helixpoin t.com

Nov 18 '05 #2
'&' in the URL should be urlencoded as %26

"DaveF" <df*****@geodec isions.com> wrote in message
news:OX******** ******@TK2MSFTN GP10.phx.gbl...
I am looping threw the querySting with:
foreach (string name in Request.QuerySt ring)

I have a problem with a '&' being in one of the values. How do I deal with
this?

page.asp?theVal =2&theVal2=aa& e overdue
--
David Fetrow
Helixpoint LLC.
http://www.helixpoint.com
da***@helixpoin t.com

Nov 18 '05 #3
No... you & is legal. Check for other:

Example:

Dim uriString As String = "http://www.contoso.com/search"
' Create a new WebClient instance.
Dim myWebClient As New WebClient()
' Create a new NameValueCollec tion instance to hold the QueryString parameters and values.
Dim myQueryStringCo llection As New NameValueCollec tion()
Console.Write(( "Enter the word(s), separated by space characters, to search for in " + uriString + ": "))
' Read user input phrase to search in uriString.
Dim searchPhrase As String = Console.ReadLin e()
' Append necessary parameter/value pairs to the name/value container.
' as QueryString = "?q=Microsoft&b tnG=Google+Sear ch".
If searchPhrase.Le ngth > 1 Then
'Assign the user-defined search phrase.
myQueryStringCo llection.Add("q ", searchPhrase)
' If error, default to search 'Microsoft'.
Else
myQueryStringCo llection.Add("q ", "Microsoft" )
End If
' Assign auxilliary parameters required for the search.
myQueryStringCo llection.Add("b tnG", "Google" + ChrW(43) + "Search")
Console.WriteLi ne(("Searching " + uriString + " ......."))
' Attach QueryString to the WebClient.
myWebClient.Que ryString = myQueryStringCo llection
' Download the search results Web page into 'searchresult.h tm' for inspection.
myWebClient.Dow nloadFile(uriSt ring, "searchresult.h tm")
Console.WriteLi ne((ControlChar s.Cr + "Download of " + uriString + " was successful. Please see 'searchresult.h tm' for results."))
"DaveF" <df*****@geodec isions.com> wrote in message news:OX******** ******@TK2MSFTN GP10.phx.gbl...
I am looping threw the querySting with:
foreach (string name in Request.QuerySt ring)

I have a problem with a '&' being in one of the values. How do I deal with
this?

page.asp?theVal =2&theVal2=aa& e overdue
--


David Fetrow
Helixpoint LLC.
http://www.helixpoint.com
da***@helixpoin t.com

Nov 18 '05 #4
Hello chanmmn,

& is legal ... as an item delimiter.

If one of your items contains a &, it needs to be escaped (%26). You can
do this manually or with Server.UrlEncod e(value). If you dont do this, then
the query string will be goofed up, because the delimiters are in the wrong
spot.

--
Matt Berther
http://www.mattberther.com
No... you & is legal. Check for other:

Example:

Dim uriString As String = "http://www.contoso.com/search"
' Create a new WebClient instance.
Dim myWebClient As New WebClient()
' Create a new NameValueCollec tion instance to hold the QueryString
parameters and values.
Dim myQueryStringCo llection As New NameValueCollec tion()
Console.Write(( "Enter the word(s), separated by space characters, to
search for in " + uriString + ": "))
' Read user input phrase to search in uriString.
Dim searchPhrase As String = Console.ReadLin e()
' Append necessary parameter/value pairs to the name/value container.
' as QueryString = "?q=Microsoft&b tnG=Google+Sear ch".
If searchPhrase.Le ngth > 1 Then
'Assign the user-defined search phrase.
myQueryStringCo llection.Add("q ", searchPhrase)
' If error, default to search 'Microsoft'.
Else
myQueryStringCo llection.Add("q ", "Microsoft" )
End If
' Assign auxilliary parameters required for the search.
myQueryStringCo llection.Add("b tnG", "Google" + ChrW(43) + "Search")
Console.WriteLi ne(("Searching " + uriString + " ......."))
' Attach QueryString to the WebClient.
myWebClient.Que ryString = myQueryStringCo llection
' Download the search results Web page into 'searchresult.h tm' for
inspection.
myWebClient.Dow nloadFile(uriSt ring, "searchresult.h tm")
Console.WriteLi ne((ControlChar s.Cr + "Download of " + uriString + "
was
successful. Please see 'searchresult.h tm' for results."))
"DaveF" <df*****@geodec isions.com> wrote in message
news:OX******** ******@TK2MSFTN GP10.phx.gbl...
I am looping threw the querySting with:
foreach (string name in Request.QuerySt ring)
I have a problem with a '&' being in one of the values. How do I deal

with
this?

page.asp?theVal =2&theVal2=aa& e overdue
--
David Fetrow
Helixpoint LLC.
http://www.helixpoint.com
da***@helixpoin t.com

Nov 18 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
17280
by: Arpan | last post by:
A link has the following URL: <a href="Page1.asp?cname=<%= Request.QueryString("cname") %>&cadd1=<%= Request.QueryString("cadd1") %>&cadd2=<%= Request.QueryString("cadd2") %>&cplace=<%= Request.QueryString("cplace") %>">Click</a> Suppose the names in the above querystring have the following values: cname="Danny" cadd1="House 97"
4
3008
by: Luklrc | last post by:
Hi, I'm having to create a querysting with javascript. My problem is that javscript turns the "&" characher into "&amp;" when it gets used as a querystring in the url EG: /mypage.asp?value1=1&amp;value2=4&amp; ... which of course means nothing to asp.
12
6308
by: ~~~ .NET Ed ~~~ | last post by:
Hi, I have a standalone XML file (with the appropriate xml document header) that works fine when I load it using XmlDocument. I can have child elements like this without problems: <SomeChildElement type="c" href="There.aspx?id=5" /> But as soon as I change it to something like this: <SomeChildElement type="c" href="There.aspx?id=5&amp;t=m"...
0
1088
by: Martin Maurer | last post by:
Hello, i have a problem with NameValueCollection.Add or better with converting to a QueryString: NameValueCollection myQueryStringCollection = new NameValueCollection(); myQueryStringCollection.Add("Test1", null); myQueryStringCollection.Add("Test2","abc"); WebClient myWebClient = new WebClient(); myWebClient.QueryString =...
2
1620
by: Mehdi | last post by:
Hi, I need to pass an URL via a hidden value as follow: <input type="hidden" id="Test" runat="Server"> and on Page_Load I assign a value to this hidden input as follow: Test.Value = "http://www.myserver.com?id=123&name=HomerSimpson";
3
2722
by: Alejandro Penate-Diaz | last post by:
Does anbody know how to clear the querystring between postbacks? tnx, alejandro.
1
2915
by: EoRaptor013 | last post by:
Not sure where to ask this question, but... I'm using a TreeView component to enable browsing file folders in a specific directory (for test purposes /Program Files/). Some users use an ampersand ("&") in both folder and file names. This has caused me some real grief! I'm not in a position to tell the users it's an ID 10 T error and they have...
2
7234
by: rn5a | last post by:
Assume that an ASPX page is accessed using the following URL: http://myserver/Page1.aspx?fname=john The value of the querystring fname (which is john) can be retrieved using both Request.Params("fname") & Request.QueryString("fname"). So what's the difference between Request.Params("fname") & Request.QueryString("fname")?
3
6653
by: Elroyskimms | last post by:
I have to encode an address which contains an ampersand (&) into a URL with various querystring parameters. The following code works fine: URLString = "www.myserver.com?AD1=" & HTTPUtility.URLEncode("500 Rt 6 & 209") and then to retrieve it: txtAddress1.text = Request.Querystring("AD1") However, in a different page of code, I loop...
3
2188
by: Tony | last post by:
I see that many pages have &amp; in querystring instead &. What is difference? Can I put page link (url) www.mysite.com/mypage.aspx?lang=EN&ID=15 or I need to write www.mysite.com/mypage.aspx?lang=EN&amp;ID=15 What is difference between & and &amp; and what is better?
0
7490
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7682
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
7935
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
7780
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6009
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5351
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
3479
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
1
1911
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
0
734
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.