Benny Sutton is 4 hire - just click here

Encode String safe for JavaScript

Convenient way to encode a string safe for javascript i.e. properly escaped

           
        public static String JavaScriptStringEncode(this String value)
        {
            return HttpUtility.JavaScriptStringEncode(value);
        }

    

Returns safe string - call like this...

         
            str += JavaScriptStringEncode(item.CategoryName);