the difference between Server.HtmlDecode and Server.HtmlEncode

  • Thread starter Thread starter Guest
  • Start date Start date
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
 
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
 
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>"
 
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?
 
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?
 
Back
Top