I receive this error when I try to use “{” to generate Javascript objects server-side to pass back to the browser: “Input string was not in a correct format.”
This happens when I do the following:
builder.AppendLine(String.Format("ID{0}: { ", application.Key.ToString())); // Does not work:
But not when I do the following:
builder.AppendLine(String.Format("ID{0}: {{ ", application.Key.ToString()));
The cause of the error is that String.Format uses “{” as mark-up. Is there a more eligant way of handcrafting Javascript serialisation in .Net?
EDIT:
We only have up to .Net 3.5 Framework installed on the server
Would the JavaScriptSerializer do what you need?