This documentation is archived and is not being maintained.

HttpServerUtility.HtmlDecode Method

Decodes a string that has been encoded to eliminate invalid HTML characters.

Overload List

Decodes an HTML-encoded string and returns the decoded string.

[Visual Basic] Overloads Public Function HtmlDecode(String) As String
[C#] public string HtmlDecode(string);
[C++] public: String* HtmlDecode(String*);
[JScript] public function HtmlDecode(String) : String;

Decodes an HTML-encoded string and sends the resulting output to a TextWriter output stream.

[Visual Basic] Overloads Public Sub HtmlDecode(String, TextWriter)
[C#] public void HtmlDecode(string, TextWriter);
[C++] public: void HtmlDecode(String*, TextWriter*);
[JScript] public function HtmlDecode(String, TextWriter);


The following example decodes a string that has been HTML-encoded for transmission over HTTP. It decodes the supplied string named EncodedString which contains the text "This is a &ltTest String&gt.", and copies it into the string named DecodedString as "This is a <Test String>."

[Visual Basic] 
Dim EncodedString As String = "This is a &ltTest String&gt."
Dim writer As New StringWriter
Server.HtmlDecode(EncodedString, writer)
Dim DecodedString As String = writer.ToString()

String EncodedString = "This is a &ltTest String&gt.";
StringWriter writer = new StringWriter();
Server.HtmlDecode(EncodedString, writer);
String DecodedString = writer.ToString();

String* EncodedString = S"This is a &ltTest String&gt.";
StringWriter* writer = new StringWriter();
Server->HtmlDecode(EncodedString, writer);
String* DecodedString = writer->ToString();

var encodedString : String = "This is a &ltTest String&gt."
var writer : StringWriter = new StringWriter()
Server.HtmlDecode(encodedString, writer)
var decodedString : String = writer.ToString()

See Also

HttpServerUtility Class | HttpServerUtility Members | System.Web Namespace