Monday, August 1, 2011

Format Text for Input



To Clear Special Characters


public static string FormatTextForInput(string Text)
    {
        if (Text == "")
            return "";

        if (Text == null)
            return "";

        string output = Text;

        //Build an array of characters that need to be filter.
        string[] strDirtyInput = { "xp_", ";", "--", "<", ">", "iframe", "script","#","!","#","^","&","*","~","%","$","@" };

        //Loop through all items in the array
        foreach (string item in strDirtyInput)
        {
            output = output.Replace(item, "");
        }

        output = output.Replace("'", "''");

        return output;
    }


0 comments:

Post a Comment

Twitter Delicious Facebook Digg Stumbleupon Favorites More