preventing html encoding by server control

A

Amie

Hi,

It seems asp.net controls automatically encode the attribute values.

For example, I need to have whitespace in OPTION tag. After binding
data to the dropdownlist, the source html has the following:

<option value="1">&amp;nbsp; North America</option>

Also, when I assign an attribute to a generic html control with
ampersand, it encodes it as well.

<param id="chart_param" name="movie" value="charts.swf?
xml_source=xml.aspx?hID=0&amp;cID=acomChart"></param>

Note that the querystring is broken because of this.

Is there any way to prevent server controls from automatically
encoding the values??

I've tried the following:
- HttpUtility.HtmlDecode
doesn't work cuz any special characters the output has will be encoded
again
- \&
doesn't work in c#

I'd like to avoid overwriting render method of dropdownlist if it's
possible..

Any suggestion is appreciated.

Thanks,
Amie
 
N

Nicholas Paldino [.NET/C# MVP]

Amie,

I am not sure what you would do for the option tag, but for the URL,
when generating the URL encoding, you should use the UrlEncode method on
either the HttpUtility or HttpServerUtility class.

Hope this helps.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top