I am using Flexigrid in my project to add a button on the grid toolbar I can use code like this:
...
"buttons":[
{"name":"Modifica","bclass":"edit","onpress":"doCommand"},
{"name":"Elimina","bclass":"delete","onpress":"doCommand"}
],
...
Anyway the “onpress” attribute shall contain a reference to a js callback and so this field shall not be enclosed within quotation marks.
I am using the class JavaScriptSerializer (in the System.Web.Script.Serialization namespace) to do the serialization.
How I have to declare the variable to make JavaScriptSerializer serialize like this?
...
"buttons":[
{"name":"Modifica","bclass":"edit","onpress":doCommand},
{"name":"Elimina","bclass":"delete","onpress":doCommand}
],
...
Thanks for helping!
To the best of my knowledge, there is not a native way to do this with the .NET serializer, but you could execute the following code on the client-side to turn the
onpressJSON string into a callback…