A
Andrea Williams
I have a class that imports System.Web.UI.Page. The code below works:
public string JScriptEncode(string strValue)
{
strValue = strValue.Replace(@"'", "\x27"); //' JScript encode apostrophes
strValue = strValue.Replace(@"""", "\x22"); //' JScript encode double-quotes
strValue = Server.HtmlEncode(strValue); //' encode chars special to HTML
return strValue;
}
But as soon as I add the keyword "static" to the function, the
Server.HTMLEncode call fails. But if I don't use the "static" keyword, then
my pages cannot access it and use it. Am I missing something here? Is
there another .Net call I should be using instead?
Thanks,
Andrea
public string JScriptEncode(string strValue)
{
strValue = strValue.Replace(@"'", "\x27"); //' JScript encode apostrophes
strValue = strValue.Replace(@"""", "\x22"); //' JScript encode double-quotes
strValue = Server.HtmlEncode(strValue); //' encode chars special to HTML
return strValue;
}
But as soon as I add the keyword "static" to the function, the
Server.HTMLEncode call fails. But if I don't use the "static" keyword, then
my pages cannot access it and use it. Am I missing something here? Is
there another .Net call I should be using instead?
Thanks,
Andrea