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)