Hi everyone im working on getting an excellent function together for encoding symbols to ascii, the issue im having is that i get an error stating: Name 'Server' is not declared. I have the htmlencode function working on another page, so i tried adding Inherits System.Web.UI.Page to the class but then i get this error: Cannot refer to an instance member of a class from within a shared method or a shared member initializer without an explicit instance of the class.
This file is imported by all the page vb files since it contains several other functions that theyll need its name and code are below:
app_code/functions.vb
vbnet Code:
Imports Microsoft.VisualBasic
Imports System.Data.SqlClient
Imports System.Data
Imports System.Web
Imports Microsoft.Practices.EnterpriseLibrary.Data
Imports Microsoft.Practices.EnterpriseLibrary.Data.Sql
Public Class functions
Inherits System.Web.UI.Page
'===================================================================
' Helper function to encode characters, this will be used with the
' special helper functions that accomodate DAAB, use these functions
' everytime data hits a database or is printed to the screen.
' Preferablly as soon as you get the data and before any checkers
'===================================================================
Public Shared Function makeSafe(ByVal strToSanitize As String) As String
Dim sanitizedStr As String
' Convert symbols into ascii
sanitizedStr = Replace(strToSanitize, ";", ";")
sanitizedStr = Server.HtmlEncode(sanitizedStr)
sanitizedStr = Replace(sanitizedStr, "'", "'")
sanitizedStr = Replace(sanitizedStr, """", """)
sanitizedStr = Replace(sanitizedStr, "-", "-")
sanitizedStr = Replace(sanitizedStr, "+", "+")
sanitizedStr = Replace(sanitizedStr, "=", "=")
sanitizedStr = Replace(sanitizedStr, ":", ":")
sanitizedStr = Replace(sanitizedStr, "(", "(")
sanitizedStr = Replace(sanitizedStr, ")", ")")
Return sanitizedStr
End Function
Any ideas on how to fix the errors?