Passing complex objects to javascript via IScriptControl
- by Jeff Dege
I'm playing around with a asp.net page that's using the IScriptControl interface to pass data from the code-behind to the custom javascript object running on the browser.
I'm passing a number of properties via IScriptControl.GetScriptDescriptors(), and they're all working fine, except for one.
That one is a class derived from System.Collections.Generic.Dictionary<. And even that one has been working for me, so long as the elements in the collection were scalars - ints, doubles, and strings. But when I tried to pass a member of a class, it showed up as a null object in the javascript. The class in question is marked [Serializable]. I changed it to a struct, and got the same behavior.
It looks as if the serializer used in IScriptControl does a shallow copy. I need a deep copy.
Any ideas?