473,385 Members | 2,015 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,385 software developers and data experts.

preventing html encoding by server control

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

May 9 '07 #1
1 3181
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.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Amie" <am*******@gmail.comwrote in message
news:11*********************@u30g2000hsc.googlegro ups.com...
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

May 10 '07 #2

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

Similar topics

1
by: Mohan | last post by:
Hi All, I am using web browser control in a VB 6.0 client server application to print reports. I am writing the report into a HTML file and displays the report to the user using the code,...
1
by: David Hane | last post by:
Hi all, I would like give users the ability to experiment with complex queries but I'm worried about them creating queries that will bog down the server. Does anyone have any ideas for...
4
by: Qaurk Noble | last post by:
Can anyone help? I need to html encode all text field values on the client just before sending them to the server. A javascript equilalent of Server.HTMLEncode in IIS. I also need to be able...
0
by: Guogang | last post by:
I find that the HTML encoding of asp web controls are inconsistent. Say, I want to show the string "<script> alter("test") <script>". For a "BoundColumn" used in DataGrid, I get an *real alert...
5
by: David Elliott | last post by:
I need a control on a Web Page that can accept an HTML Document and will display it. Any help would be appreciated. Thanks, Dave Here is what I was trying...
7
by: Steve Bugden | last post by:
Hi, I am trying to reference an html page from an aspx file. The intention is that the html file will contain the content for my web site and the aspx will contain the navigation, logo etc. Then...
15
by: Nathan | last post by:
I have an aspx page with a data grid, some textboxes, and an update button. This page also has one html input element with type=file (not inside the data grid and runat=server). The update...
82
by: Eric Lindsay | last post by:
I have been trying to get a better understanding of simple HTML, but I am finding conflicting information is very common. Not only that, even in what seemed elementary and without any possibility...
1
by: cnixuser | last post by:
Hello, I am having a problem that I believe is related to the way a stream reader object looks for a text file by default. What I am doing is using a StreamReader object to read the text of a text...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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
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
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
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...

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.