Passing complex objects to javascript via IScriptControl

Posted by Jeff Dege on Stack Overflow See other posts from Stack Overflow or by Jeff Dege
Published on 2010-03-24T23:18:17Z Indexed on 2010/03/24 23:23 UTC
Read the original article Hit count: 346

Filed under:
|

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?

© Stack Overflow or respective owner

Related posts about ASP.NET

Related posts about iscriptcontrol