Hi,
The following is lifted straight from the MSDN help topic for
HttpServerUtility.HtmlEncode Method [C#]
---------------------------------------------------------------
The following example encodes a string for transmission by HTTP. It encodes
the string named TestString, which contains the text "This is a <Test
String>.", and copies it into the string named EncodedString as
"This+is+a+%3cTest+String%3e.".
[C#]
String TestString = "This is a <Test String>.";
StringWriter writer = new StringWriter();
Server.HtmlEncode(TestString, writer);
String EncodedString = writer.ToString();
---------------------------------------------------------------
However, when I run it, the value of EncodedString is "This is a <Test
String>." not "This+is+a+%3cTest+String%3e."
Am I missing something? Am I not using the correct encoding method?
Any assistance gratefully received.
Best,
Mark Rae 3 5721
Hi,
Use Server.UrlEncode for the output you are expecting.
"Mark Rae" <ma**@mark-N-O-S-P-A-M-rae.co.uk> wrote in message
news:eB*************@TK2MSFTNGP11.phx.gbl...
Hi,
The following is lifted straight from the MSDN help topic for
HttpServerUtility.HtmlEncode Method [C#]
---------------------------------------------------------------
The following example encodes a string for transmission by HTTP. It encodes
the string named TestString, which contains the text "This is a <Test
String>.", and copies it into the string named EncodedString as
"This+is+a+%3cTest+String%3e.".
[C#]
String TestString = "This is a <Test String>.";
StringWriter writer = new StringWriter();
Server.HtmlEncode(TestString, writer);
String EncodedString = writer.ToString();
---------------------------------------------------------------
However, when I run it, the value of EncodedString is "This is a <Test
String>." not "This+is+a+%3cTest+String%3e."
Am I missing something? Am I not using the correct encoding method?
Any assistance gratefully received.
Best,
Mark Rae
Mark Rae wrote: Hi,
The following is lifted straight from the MSDN help topic for HttpServerUtility.HtmlEncode Method [C#]
--------------------------------------------------------------- The following example encodes a string for transmission by HTTP. It encodes the string named TestString, which contains the text "This is a <Test String>.", and copies it into the string named EncodedString as "This+is+a+%3cTest+String%3e.".
[C#] String TestString = "This is a <Test String>."; StringWriter writer = new StringWriter(); Server.HtmlEncode(TestString, writer); String EncodedString = writer.ToString(); ---------------------------------------------------------------
However, when I run it, the value of EncodedString is "This is a <Test String>." not "This+is+a+%3cTest+String%3e."
Am I missing something? Am I not using the correct encoding method?
Any assistance gratefully received.
Best,
Mark Rae
Try Server.UrlEncode instead. HtmlEncode is generating HTML, as it
would be expected to.
-Mike
"Mike Newton" <MN*****@Addus.com> wrote in message
news:ew**************@TK2MSFTNGP10.phx.gbl...
Mike & Silva, Try Server.UrlEncode instead. HtmlEncode is generating HTML, as it would be expected to.
Thanks very much. Is the MSDN topic wrong, then...? This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Hraklhs |
last post by:
Is it useful to ALWAYS use Server.HTMLEncode when writing data read from a db? Ex.
Response.Write (Server.HTMLEncode(var)) instead of Response.Write var
|
by: abcd |
last post by:
Simple but not working at this moment
I have to fill the HTML select control....
my values could be for example "test number 1"
sample code,
dim x
Data = "test ...
|
by: Andrea Williams |
last post by:
I have a class that imports System.Web.UI.Page. The code below works:
public string JScriptEncode(string strValue)
{
strValue = strValue.Replace(@"'", "\x27"); //' JScript encode...
|
by: Michael Gaillez |
last post by:
Hi,
I'm dynamically loading an assembly into an ASP.NET application. In the
control that I load from that dynamic assembly I've tried to use
Server.HTMLEncode but this results in a serious...
|
by: TCB |
last post by:
Hi,
There are a couple of things that are bothering me, any help on these is
greatly appreciated. This is using ASP.NET 2.0
1. I am sending email in my web app, using a simple form here is the...
|
by: Fossie |
last post by:
Can anyone help with Server.HtmlEncode encoding this?
'<%# DataBinder.Eval(Container.DataItem, "CAT_ID",
"pageview.aspx?tab=1&catid={0}") %>
I've tried using similar to this:
<%#...
|
by: Marco Miltenburg |
last post by:
While working on some multilingual code I found a rather strange thing
happening with Server.HTMLEncode.
While loading different languages I change the Codepage and Charset in
ASP to reflect the...
|
by: burnsy2000 |
last post by:
We are running ASP classic on IIS 5 on W2k SP4. We recently added <%
Response.charset="utf-8"%to the top of all our pages (as suggested by
validator.w3.org). A problem arose on a page which applies...
|
by: teddysnips |
last post by:
In my application I need to allow users to cut 'n' paste stuff from
various sources, some of which might include dodgy characters such as
"<". Natch, IE interprets these as potentially dangerous...
|
by: DolphinDB |
last post by:
Tired of spending countless mintues downsampling your data? Look no further!
In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: Vimpel783 |
last post by:
Hello!
Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
|
by: jfyes |
last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
|
by: PapaRatzi |
last post by:
Hello,
I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
|
by: Shællîpôpï 09 |
last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
|
by: af34tf |
last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
|
by: Faith0G |
last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
| |