I've been trying to figure out why this isn't valid (according to VS2008).
//Global variable
var sortFields;
$(document).ready(function() {
sortFields = <%= CustomHtmlHelper.ToJson(ViewData["SortInfo"])%>;
//Other Code here...
});
My HtmlHelper code
public static string ToJson(object obj)
{
var serializer = new JavaScriptSerializer();
var json = serializer.Serialize(obj);
return json;
}
The Helper is generating valid Json (confirmed it), but when I'm trying to add anything else to the function, VS2008 complains about all sort kinds of stuff, can't align the code correctly and so on when closing brackets, and as soon as I comment this out it works. However, the code works fine, even if VS2008 complains about it. Is this just VS2008 that is crap with JQuery or am I actually doing something wrong?