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

Chris at globet.com Chris at globet.com
Thu Sep 7 07:24:28 CDT 2006


Thanks for the responses. I haven't had time to address this particular
problem any further, but I'll post if I find a solution. I understand
what you're saying, but I still don't see why ampersands would (or
should) be HTML encoded. Unfortunately I cannot change the string that
I'm using, as it comes from a database. I get the same issue whether or
not I use the string from the database or hard-code it as a string

Anyway, thanks again.

> I think Matt is right.
> > I am not a .NET guy, but nothing I can find in the docs 
> suggests that 
> > the string passed to the constructor will be interpreted as 
> markup. I 
> > suspect it is simply a string of characters. If they are characters 
> > you can't figure out how to type or otherwise can't declare them 
> > literally, you will need to represent them another way. 
> Most languages 
> > have something like chr(10) and such, to convert from ascii (or
> > other) code to the character.
> You could try using Server.HtmlDecode()? I haven't tested it 
> but it might be worth a go. This assumes your code is within 
> a class that derives from Page (i.e. within the code-behind 
> of a web page):
> 	DropDownList languageDropDownList = new DropDownList();
> 	string s = "Ελληνικά";
> 	this.languageDropDownList.Items.Add(new
> ListItem(Server.HtmlDecode(s), "gr"));

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. 

More information about the thelist mailing list