2013年9月25日 星期三

將HTML標籤轉成文字-HtmlEncode


'在前台<%@ Page %>'插入ValidateRequest="false"
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="_Default"  ValidateRequest="false"%>
' Visual BasicPrivate Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim userinput As String = TextBox1.Text
userinput = Server.HtmlEncode(userinput)' Accepts , case-insensitive
userinput = userinput.Replace("<b>", "")
userinput = userinput.Replace("</b>", "
")
userinput = userinput.Replace("<B>", "")
userinput = userinput.Replace("</B>", "
")
userinput = userinput.Replace("<u>", "")
userinput = userinput.Replace("</u>", "
")
userinput = userinput.Replace("<U>", "")
userinput = userinput.Replace("</U>", "
")
Label1.Text = userinput
End Sub

沒有留言:

張貼留言