Filter HTML Format

Source: Internet
Author: User

When we use textbox to submit content, when the page displays the content of Textbox, the HTML format will produce some negative effects on the page display. Therefore, we need to filter out the HTML format. The following are code blocks in HTML format.

1. first introduce the namespace
2 imports system. Text. regularexpressions
3 code blocks:
4 public shared function htmlencode () function htmlencode (byval restring as string) 'convert HTML code
5 Dim STR as string = restring
6 if Str. length> 0 then
7 STR = Replace (STR, ">", "& gt ;")
8 STR = Replace (STR, "<", "& lt ;")
9 STR = Replace (STR, CHR (9), "& nbsp ;")
10 STR = Replace (STR, CHR (39 ),"'")
11 STR = Replace (STR, CHR (34), "& quot ;")
12 STR = Replace (STR, CHR (13 ),"")
13 STR = Replace (STR, CHR (10), "<br/> ")
14 htmlencode = Str
15 end if
16 end function1 <% @ page Language = "VB" validaterequest = "false" autoeventwireup = "false" codebehind = "test. aspx. VB" inherits = "_ 03_et.test" %>
2. Add validaterequest = "false" to the HTML page"
3

Recent call
Label1.text = parm. htmlencode (textbox1.text)

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.