the difference between Server.HtmlDecode and Server.HtmlEncode

G

Guest

hiye guys, i've read the documentation and i dont really understand the difference between these two
Server.HtmlDecode and Server.HtmlEncode. can someone plz clear the air for me
thank

smen
 
J

Jim Cheshire [MSFT]

Hi Smen,

Server.HtmlEncode encodes data and should be performed anytime that you are
allowing for free text in an input field. Server.HtmlDecode decodes data
that have been encoded with Server.HtmlEncode.

Jim Cheshire, MCSE, MCSD [MSFT]
ASP.NET
Developer Support Engineer
(e-mail address removed)

This post is provided "AS-IS" with no warranties and confers no rights.

--------------------
Thread-Topic: the difference between Server.HtmlDecode and Server.HtmlEncode
thread-index: AcQQP1WXza++wZFSSsibhtK9pOToNA==
X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet
From: "=?Utf-8?B?c21lbg==?=" <[email protected]>
Subject: the difference between Server.HtmlDecode and Server.HtmlEncode
Date: Mon, 22 Mar 2004 10:56:07 -0800
Lines: 6
Message-ID: <[email protected]>
MIME-Version: 1.0
Content-Type: text/plain;
charset="Utf-8"
Content-Transfer-Encoding: 7bit
X-Newsreader: Microsoft CDO for Windows 2000
Content-Class: urn:content-classes:message
Importance: normal
Priority: normal
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.0
Newsgroups: microsoft.public.dotnet.framework.aspnet
Path: cpmsftngxa06.phx.gbl
Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.framework.aspnet:220397
NNTP-Posting-Host: tk2msftcmty1.phx.gbl 10.40.1.180
X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet

hiye guys, i've read the documentation and i dont really understand the
difference between these two.
Server.HtmlDecode and Server.HtmlEncode. can someone plz clear the air for
me?
thanks


smen
 
R

Raterus

HtmlEncode takes a string like this "an html tag: <img>"
and returns a string like this: "an html tag: &lt;img&gt;"

HtmlDecode takes a string like one HtmlEncode would create: "an html tag:
&lt;img&gt;"
and creates one like you originally had: "an html tag: <img>"
 
G

Guest

so when i save into the db, i should encode it and when i display on to the browser i should decode it. am i right?
 
G

George Ter-Saakov

Nope.
When you are outputting it to the browser you should encode it.
Usually you do not need to decode it. It's a browser job.

George.



smen said:
so when i save into the db, i should encode it and when i display on to
the browser i should decode it. am i right?
 

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

Top