System.Web Namespace HttpServerUtility Class
Decodes an HTML-encoded string and sends the resulting output to a TextWriter output stream.
[ VB ]
Overloads Public Sub HtmlDecode ( _
ByVal s As String, _
ByVal output As TextWriter _
)
[ C# ]
public void HtmlDecode (
string s,
TextWriter output
);
[ C++ ]
public: void HtmlDecode (
String* s,
TextWriter* output
);
[ JScript ]
public function HtmlDecode (
s : String,
output : TextWriter
);
- s
- The HTML string to decode.
- output
- The TextWriter output stream containing the decoded string.
URL encoding ensures that all browsers will correctly transmit text in URL strings. Characters such as "?", "&", "/", and spaces may be truncated or corrupted by some browsers so those characters cannot be used in ASP.NET pages in "<A>" tags or in querystrings where the strings may be sent by a browser in a request string. HtmlDecode decodes text that has been transmitted to the server.
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 <Test String>.", and copies it into the string named DecodedString as "This is a <Test String>."
[ VB ]
Dim EncodedString As String = "This is a <Test String>."
Dim writer As New StringWriter
Server.HtmlDecode ( EncodedString, writer )
Dim DecodedString As String = writer.ToString ( )
[ C# ]
String EncodedString = "This is a <Test String>.";
StringWriter writer = new StringWriter ( );
Server.HtmlDecode ( EncodedString, writer );
String DecodedString = writer.ToString ( );
HttpServerUtility Members HttpServerUtility.HtmlDecode Overload List