Rather than setting up lengthy filtering operations, consider using the HTMLEncode function, which will encode legitimate characters to prevent harm. HTMLEncode works by changing the less-than character (<) to <, the greater-than character (>)to >, the ampersand (&) to &, double quotes to " and any ASCI code greater than 0x80 to &# followed by the ASCII number. This is a server-side operation using ASP.NET 3.5 and called by this code in Visual Basic:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Label1.Text = Server.HtmlEncode(TextBox1.Text)
However, implementation can be a bit tricky. Users interested in exploring this method should visit the Microsoft Developer Network site listed in Additional Resources.