
394
|
Chapter 18: The HttpServerUtility Class
This is the Title of the Book, eMatter Edition
Copyright © 2008 O’Reilly & Associates, Inc. All rights reserved.
StrToReturn = Server.HtmlDecode(StrToDecode)
Message.Text = StrToReturn
End Sub
Notes
This method provides a simple way to undo the effects of calling HtmlEncode on
a given string. You can also use it as an educational tool to demonstrate the rela-
tionship between various characters used in HTML and ASP (such as the greater-
than (>) and less-than (<) symbols) and their encoded equivalents.
When called with only the
s argument, this method returns a string. When called
with both an
s argument and an output argument (such as a StringWriter or
HtmlTextWriter class instance), the method does not return a value; instead, you
can obtain the decoded string by calling the ToString method of the writer object.
While this method is useful, you probably won’t use it as frequently as its cousin,
UrlDecode, which is described later in this chapter.
HtmlEncode
returnstring = Server.HtmlEncode(s)
Server.HtmlEncode(s, output)
Returns a string in which any HTML tags found are encoded by using the HTML
literal equivalents of symbols such as > (
>),<(<), and even quotes (").
This allows developers to display HTML and ASP source code on the page, rather
than treating it as rendered output or code to execute.
Parameters
returnstring
A String variable to receive ...