[thelist] .NET [C#], DropDownList, HTMLEncode

Robert Vreeland vreeland at studioframework.com
Thu Sep 7 09:06:23 CDT 2006

Sorry if this has already been suggested, but have you tried designating
your input as a verbatim string literal? You do so by putting an @ before
the leading  double quote like so:

DropDownList languageDropDownList = new DropDownList();

ListItem(&"Ελληνικά", "gr"));

The following is from the .net 1.1 sdk
C# supports two forms of string literals: regular string literals and
verbatim string literals.

A regular string literal consists of zero or more characters enclosed in
double quotes, as in "hello", and may include both simple escape sequences
(such as \t for the tab character) and hexadecimal and Unicode escape

A verbatim string literal consists of an @ character followed by a
double-quote character, zero or more characters, and a closing double-quote
character. A simple example is @"hello". In a verbatim string literal, the
characters between the delimiters are interpreted verbatim, the only
exception being a quote-escape-sequence. In particular, simple escape
sequences and hexadecimal and Unicode escape sequences are not processed in
verbatim string literals. A verbatim string literal may span multiple lines.


Hope this helps.
Robert Vreeland

-----Original Message-----
From: thelist-bounces at lists.evolt.org
[mailto:thelist-bounces at lists.evolt.org] On Behalf Of Chris at globet.com
Sent: Thursday, September 07, 2006 8:48 AM
To: thelist at lists.evolt.org
Cc: Chris at globet.com
Subject: Re: [thelist] .NET [C#], DropDownList, HTMLEncode



> The thought is that it is *not* being treated as if it were 
> HTML-encoded. It is being treated as a literal string. So, if you type 
> "&amp;", you will get "&amp;" just as if you had typed "asdf" and got 
> "asdf".

To clarify: the input string *is* "&#241;" the ouput string *is*
"&amp;#241;". What I require is that the input string *should be* "&#241;"
and the output string *should be* "&#241;". Hence my belief that somewhere
in the process of assigning the string value to a DropDownList item via a
ListItem object, an HTML encoding method is being executed on the string.

Apologies, either my powers of expression or my powers of comprehension have
not been what they should have been over the past couple of days :)

Chris Marsh
Software Developer
t: +44 20 8246 4804 x828
f: +44 20 8246 4808
e: chris at globet.com
w: http://www.globet.com/

Any opinions expressed in this email are those of the individual and not
necessarily the Company. This message is intended for the use of the
individual or entity to which it is addressed and may contain information
that is confidential and privileged and exempt from disclosure under
applicable law. If the reader of this message is not the intended recipient,
you are hereby notified that any dissemination, distribution, or copying of
this communication is strictly prohibited.
If you have received this communication in error, please contact the sender
immediately and delete it from your system. 

* * Please support the community that supports you.  * *

For unsubscribe and other options, including the Tip Harvester and archives
of thelist go to: http://lists.evolt.org Workers of the Web, evolt ! 

More information about the thelist mailing list