473,395 Members | 1,937 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

encoding of "&" vs "&" in url

I am having a bear of a time with setting a URL query string as a text value
in a dropdownlist and Server.URLEncode does not seem to do its job.

theFullLink = theLinkPrefix & theImageryTypeTrimmed &
Server.URLEncode("&f=")
ddlMyDropDownList.Items.Add(New ListItem("MyTextValue", theFullLink & "af"))

Which puts out the following HTML:

<option value="~/folder/page.aspx?param1=value1%26f%3daf">-
Afghanistan</option>

If I leave off the Server.URLEncode() i get:

<option value="~/folder/page.aspx?param1=value1&amp;f=af">-
Afghanistan</option>

Help!

_____
DC G
Nov 21 '05 #1
7 1535

"DC Gringo" <dc******@visiontechnology.net> wrote in message
news:OC**************@TK2MSFTNGP12.phx.gbl...
If I leave off the Server.URLEncode() i get:

<option value="~/folder/page.aspx?param1=value1&amp;f=af">-
Afghanistan</option>

Help!


This output seems correct to me. What were you expecting?

- Oliver
Nov 21 '05 #2
I was expecting:

<option value="~/folder/page.aspx?param1=value1&f=af">- Afghanistan</option>

This dropdownlist is being posted back and it does not work as is...
____
DC G
"Oliver Wong" <ow***@castortech.com> wrote in message
news:cuuIe.207802$on1.77081@clgrps13...

"DC Gringo" <dc******@visiontechnology.net> wrote in message
news:OC**************@TK2MSFTNGP12.phx.gbl...
If I leave off the Server.URLEncode() i get:

<option value="~/folder/page.aspx?param1=value1&amp;f=af">-
Afghanistan</option>

Help!


This output seems correct to me. What were you expecting?

- Oliver

Nov 21 '05 #3
Try passing the character entity & instead of the ampersand.

<%= Clinton Gallagher
METROmilwaukee (sm) "A Regional Information Service"
NET csgallagher AT metromilwaukee.com
URL http://metromilwaukee.com/
URL http://clintongallagher.metromilwaukee.com/
"DC Gringo" <dc******@visiontechnology.net> wrote in message
news:Ob**************@TK2MSFTNGP14.phx.gbl...
I was expecting:

<option value="~/folder/page.aspx?param1=value1&f=af">-
Afghanistan</option>

This dropdownlist is being posted back and it does not work as is...
____
DC G
"Oliver Wong" <ow***@castortech.com> wrote in message
news:cuuIe.207802$on1.77081@clgrps13...

"DC Gringo" <dc******@visiontechnology.net> wrote in message
news:OC**************@TK2MSFTNGP12.phx.gbl...
If I leave off the Server.URLEncode() i get:

<option value="~/folder/page.aspx?param1=value1&amp;f=af">-
Afghanistan</option>

Help!


This output seems correct to me. What were you expecting?

- Oliver


Nov 21 '05 #4

"DC Gringo" <dc******@visiontechnology.net> wrote in message
news:Ob**************@TK2MSFTNGP14.phx.gbl...
I was expecting:

<option value="~/folder/page.aspx?param1=value1&f=af">-
Afghanistan</option>

This dropdownlist is being posted back and it does not work as is...


Unfortunately, I don't think the above is legal XML (and therefor not
valid XHTML either). The ampersign means that the next few characters will
refer to an entity reference, but entity references are always terminsated
by a semicolon, and there is no semicolon after the ampersign. I'm assuming
you want the "value" attribute to have the following value:
"~/folder/page.aspx?param1=value1&f=af". To express that in XML, you'd have
to escape the ampersign so that what actually appears in the XML file is
"~/folder/page.aspx?param1=value1&amp;f=af".

This is similar to the concept that to represent the string which only
contains one instance of the character \, you have to type it in as "\\" or
@"\" in C#.

- Oliver
Nov 21 '05 #5
Clinton,

Thanks for the suggestion, but it didn't work...the result was:

<option value="~/centers/innerSections.aspx?pageID=ndvi&amp;#38;f=af">-
Afghanistan</option>

_____
DC G

"clintonG" <cs*********@REMOVETHISTEXTmetromilwaukee.com> wrote in message
news:OL**************@tk2msftngp13.phx.gbl...
Try passing the character entity & instead of the ampersand.

<%= Clinton Gallagher
METROmilwaukee (sm) "A Regional Information Service"
NET csgallagher AT metromilwaukee.com
URL http://metromilwaukee.com/
URL http://clintongallagher.metromilwaukee.com/
"DC Gringo" <dc******@visiontechnology.net> wrote in message
news:Ob**************@TK2MSFTNGP14.phx.gbl...
I was expecting:

<option value="~/folder/page.aspx?param1=value1&f=af">-
Afghanistan</option>

This dropdownlist is being posted back and it does not work as is...
____
DC G
"Oliver Wong" <ow***@castortech.com> wrote in message
news:cuuIe.207802$on1.77081@clgrps13...

"DC Gringo" <dc******@visiontechnology.net> wrote in message
news:OC**************@TK2MSFTNGP12.phx.gbl...
If I leave off the Server.URLEncode() i get:

<option value="~/folder/page.aspx?param1=value1&amp;f=af">-
Afghanistan</option>

Help!

This output seems correct to me. What were you expecting?

- Oliver



Nov 21 '05 #6
Oliver,

Thank you for the explanation...that seems to make good sense.

However, I still have to implement this code somehow. How else can I do
this?

theFullLink = theLinkPrefix & theImageryTypeTrimmed & "&f="
ddlGotoRegionCountryCenter.Items.Add(New ListItem("- countryName",
theFullLink & "af"))

To get this output:

<option value="~/folder/page.aspx?param1=value1&f=af">- countryName</option>

???
_____
DC G

"Oliver Wong" <ow***@castortech.com> wrote in message
news:x_KIe.158904$HI.81946@edtnps84...

"DC Gringo" <dc******@visiontechnology.net> wrote in message
news:Ob**************@TK2MSFTNGP14.phx.gbl...
I was expecting:

<option value="~/folder/page.aspx?param1=value1&f=af">-
Afghanistan</option>

This dropdownlist is being posted back and it does not work as is...


Unfortunately, I don't think the above is legal XML (and therefor not
valid XHTML either). The ampersign means that the next few characters will
refer to an entity reference, but entity references are always terminsated
by a semicolon, and there is no semicolon after the ampersign. I'm
assuming you want the "value" attribute to have the following value:
"~/folder/page.aspx?param1=value1&f=af". To express that in XML, you'd
have to escape the ampersign so that what actually appears in the XML file
is "~/folder/page.aspx?param1=value1&amp;f=af".

This is similar to the concept that to represent the string which only
contains one instance of the character \, you have to type it in as "\\"
or @"\" in C#.

- Oliver

Nov 21 '05 #7

"DC Gringo" <dc******@visiontechnology.net> wrote in message
news:OB****************@TK2MSFTNGP12.phx.gbl...
Oliver,

Thank you for the explanation...that seems to make good sense.

However, I still have to implement this code somehow. How else can I do
this?


The point I'm getting at is that the text you're trying to output isn't
valid XML, so assuming you want to output XML (e.g. HTML), you should never
need to put an ampersign like that.

However, if for some reasons, you have clients or something which demand
this kind of output, then try emitting the data as plain text instead of
HTML; that way, you won't have any sort of escaping mechanism interfering.

- Oliver
Nov 21 '05 #8

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

Similar topics

2
by: Eric Osman | last post by:
Hi, I'm looking for a javascript function that will convert input such as this: <CLUB Code=" into this: &lt;CLUB Code=&quot;
4
by: barney | last post by:
Hello, I' m using .NET System.Xml.XmlDOcument. When I do the following: XmlDocument xml = new XmlDocument(); xml.Load("blah"); .... xml.Save("blub"); I've got the problem that the following...
5
by: martin | last post by:
Hi, I would be extremly grateful for some help on producing an xml fragemt. The fragment that I wish to produce should look like this <Addresses> <Address>&qout;Somebody's Name&quot;...
3
by: DC Gringo | last post by:
I have an image control (that pulls an image off an ESRI map server): <ASP:IMAGE ID="imgZonedCountry" RUNAT="server"></ASP:IMAGE> In the code behind I am setting the ImageURL to a String value...
7
by: DC Gringo | last post by:
I am having a bear of a time with setting a URL query string as a text value in a dropdownlist and Server.URLEncode does not seem to do its job. theFullLink = theLinkPrefix &...
3
by: beachboy | last post by:
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...
14
by: Arne | last post by:
A lot of Firefox users I know, says they have problems with validation where the ampersand sign has to be written as &amp; to be valid. I don't have Firefox my self and don't wont to install it only...
2
by: imonline | last post by:
Hi, I am generating XML and setting it into the string field. Which will be again generated into xml. Now the last xml which has xml in string field converts into "&gt" for the xml which is set...
12
by: Michel Vanderbeke | last post by:
Hello, Can you please help me? To produce a "&"-sign on the screen, I use "&&". Otherwise I get an underscore on the screen. However, when a text is in a database, and I use the same field to...
0
by: bruce | last post by:
Hi. a pretty simple question, i'm guessing. i have a text/html string that looks like: ....(A&E) the issue i have is that when i parse it using xpath/node/toString, i get the following
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
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,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
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...

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.