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

Stop ASP.NET HtmlEncoding things automatically

How can I stop ASP.NET Encoding things automatically?

e.g if I create a button in my code and add the following attribute

objNewButton.Attributes.Add("onClick", "GotoUrl('http://test.asp?X=1&Y=2');");

Then When the button is rendered into HTML the output is something like this

onClick="GotoUrl('http://test.asp?X=1&Y=2);"

Which obviously messes up the parameters in the querystring.

Is there any escape code I can pass to tell ASP.Net to leave the string alone?

Nov 19 '05 #1
6 1543
Hmm - seems this forum has its own issues with encoding/decoding!

The problem is that & is converted to &amp + semi colon!

"Martin Smith" wrote:
How can I stop ASP.NET Encoding things automatically?

e.g if I create a button in my code and add the following attribute

objNewButton.Attributes.Add("onClick", "GotoUrl('http://test.asp?X=1&Y=2');");

Then When the button is rendered into HTML the output is something like this

onClick="GotoUrl('http://test.asp?X=1&Y=2);"

Which obviously messes up the parameters in the querystring.

Is there any escape code I can pass to tell ASP.Net to leave the string alone?

Nov 19 '05 #2
check out turning off request validation for the page

http://msdn.microsoft.com/library/de...us/dnaspp/html
/scriptingprotection.asp

HTH

Ollie Riches

"Martin Smith" <Ma*********@discussions.microsoft.com> wrote in message
news:30**********************************@microsof t.com...
Hmm - seems this forum has its own issues with encoding/decoding!

The problem is that & is converted to &amp + semi colon!

"Martin Smith" wrote:
How can I stop ASP.NET Encoding things automatically?

e.g if I create a button in my code and add the following attribute

objNewButton.Attributes.Add("onClick", "GotoUrl('http://test.asp?X=1&Y=2');");
Then When the button is rendered into HTML the output is something like this
onClick="GotoUrl('http://test.asp?X=1&Y=2);"

Which obviously messes up the parameters in the querystring.

Is there any escape code I can pass to tell ASP.Net to leave the string alone?

Nov 19 '05 #3
Hi Ollie,

So far as I can see all that will allow me to do is allow users to submit
HTML in a form?

I don't see how that would help my problem?

Cheers,

Martin

"Ollie Riches" wrote:
check out turning off request validation for the page

http://msdn.microsoft.com/library/de...us/dnaspp/html
/scriptingprotection.asp

HTH

Ollie Riches

"Martin Smith" <Ma*********@discussions.microsoft.com> wrote in message
news:30**********************************@microsof t.com...
Hmm - seems this forum has its own issues with encoding/decoding!

The problem is that & is converted to & + semi colon!

"Martin Smith" wrote:
How can I stop ASP.NET Encoding things automatically?

e.g if I create a button in my code and add the following attribute

objNewButton.Attributes.Add("onClick", "GotoUrl('http://test.asp?X=1&Y=2');");
Then When the button is rendered into HTML the output is something like this
onClick="GotoUrl('http://test.asp?X=1&Y=2);"

Which obviously messes up the parameters in the querystring.

Is there any escape code I can pass to tell ASP.Net to leave the string alone?


Nov 19 '05 #4
=?Utf-8?B?TWFydGluIFNtaXRo?= <Ma*********@discussions.microsoft.com>
confessed in news:30**********************************@microsof t.com:
Hmm - seems this forum has its own issues with encoding/decoding!

The problem is that & is converted to &amp + semi colon!

"Martin Smith" wrote:
How can I stop ASP.NET Encoding things automatically?

e.g if I create a button in my code and add the following attribute

objNewButton.Attributes.Add("onClick", "GotoUrl('http://test.asp?X=1&Y= 2');");
Then When the button is rendered into HTML the output is something like this
onClick="GotoUrl('http://test.asp?X=1&Y=2);"

Which obviously messes up the parameters in the querystring.

Is there any escape code I can pass to tell ASP.Net to leave the string alone?

As far as what you're currently seeing, it's probably your browser's display
that's encoding the ampersands, etc. It's a bug.

Use a Newsreader like Agent or Xnews, and everything will look OK.

-- ipgrunt
Nov 19 '05 #5
Martin,

Maybe you won't like this answer, but I'll tell you anyway!!

Just for once, MS actually got it right with HTML. Instead of assuming
that the world works the MS way, they actually did something to conform
to W3C specifications.

The HTML spec says that all special characters must be HTML-encoded. The
URL that you showed was in fact invalid HTML. In HTML, the ampersand
denotes the start of a special HTML entity. Your URL would be
interpreted as containing the special HTML entity &Y, which doesn't
exist. Now, most browsers (including IE) will ignore an entity that they
don't recognise, so you won't have any problems. Some browsers may
adhere more strictly to the specs and try and interpret it as an entity.
When they don't recognise it, they will simply ignore it. This will
cause problems. If, at some point in the future you have a querystring
parameter that coincides with an HTML entity name (say like "pound"),
then your parameter will be interpreted as the entity and your scripting
will break.

So, in conclusion, what you are seeing is the system fixing your invalid
code. If you want to do it right, then you should have used &amp; in the
first place, as this is the HTML entity for an ampersand. Since you
didn't, it was changed for you.

Hope this helps.

Alan
Hmm - seems this forum has its own issues with encoding/decoding!

The problem is that & is converted to &amp + semi colon!

"Martin Smith" wrote:
How can I stop ASP.NET Encoding things automatically?

e.g if I create a button in my code and add the following attribute

objNewButton.Attributes.Add("onClick",
"GotoUrl('http://test.asp?X=1&Y=2');");

Then When the button is rendered into HTML the output is something like this

onClick="GotoUrl('http://test.asp?X=1&Y=2);"

Which obviously messes up the parameters in the querystring.

Is there any escape code I can pass to tell ASP.Net to leave the
string alone?


--
Alan Silver
(anything added below this line is nothing to do with me)
Nov 19 '05 #6
>As far as what you're currently seeing, it's probably your browser's
display that's encoding the ampersands, etc. It's a bug.


Nope, the &amp; is valid HTML. What he used wasn't. This is a rare case
of MS adhering to the HTML specs instead of doing it their way.

--
Alan Silver
(anything added below this line is nothing to do with me)
Nov 19 '05 #7

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

Similar topics

14
by: Jeff | last post by:
Ok. I am creating a table in an access DB based on a form submission. This works fine. The problem I am having is, if there is a space in the submission. For example.... someone submits "The...
5
by: Paul O. Morris | last post by:
Is there a script that I can run to stop a particular SQL server service on Win2003 server? I'm looking for a similar script to restart that service as well. Thanks.
10
by: Ray5531 | last post by:
Is there a way in C# to stop garbage collector from killing our object automatically.I'd like to kill it myself?? Is there away to to do so? Thanks
3
by: Chris | last post by:
Hey, What are the usual ways to encode a sql string for safe insertion into the db? Are there handy functions like php's addslashes, etc? or should i use the Regexp, or string.Replace...
8
by: Tim_Mac | last post by:
hi, i have a group of individual radio buttons that i am running some client-side code on for the onClick event. there is a URL generated by a code block inside the onClick attribute. the...
4
by: Niels Jensen | last post by:
Hi, I'm a bit of a newbie to VB.NET so please forgive me if I get the terminology incorrect... I'm still learning :) I have a form with five numUpDown controls representing different ratios...
0
by: cell | last post by:
why the MS DTC always stop services automatically ? hi , two sql server MS DTC services stop services automatically : one server : After my anti-virus software killed a vbs virus , MS DTC...
7
by: shai | last post by:
I am working at .net 1.1, writing in c#. I have windows service with a COM object. Every unexpected time The COM object throw an error that make my service get stuck (do not respond). I can catch...
56
by: valentin tihomirov | last post by:
{ int i = 2; } int i = 1; There is no 'i' defined in the 'parent' context from the moment of declaration on. So what is the problem? They tell us they pursue language simplicity. The rule "do...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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: 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
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
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...
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...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.