asp.net| Coding: Server.HTMLEncode and Server.URLEncode are commonly used functions in ASP, and similar functions are available in asp.net: HTMLEncode and UrlEncode (note case) The following examples are presented.
Server.HTMLEncode and Server.URLEncode are very common functions used
by ASP developers. So, as may have guessed two functions
have asp.net counterparts. HtmlEncode and UrlEncode (notice case) are
Part of the System.Web.HttpUtility namespace.
**********************************
This is the code:
**********************************
<%@ Page language= "VB"%>
<%@ Import namespace= "System.Web.HttpUtility"%>
<title>htmlencode and UrlEncode the asp.net way</title>
<script language= "VB" runat= "Server" >
Sub Page_Load (sender as Object, E as EventArgs)
' Assign we test URL to a variable, Assign the variable to our
Label control
Dim Strurltext as String = "urlencode.asp?test=1&test1=2"
Strurl.text = Strurltext
' Encode the ' test URL, assign it to a variable, assign the
Variable to We label control
Dim Strurlencodetext as String = UrlEncode (Strurltext)
Strurlencode.text = Strurlencodetext
' Assign we test URL to a variable, Assign the variable to our
Label control
Dim strHTMLText as String = "Works!Strhtml.text = strHTMLText
' Encode the ' test HTML, assign it to a variable, assign the
Variable to We label control
Dim Strhtmlencodetext as String = HtmlEncode (strHTMLText)
Strhtmlencode.text = Strhtmlencodetext
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.