Sunday, March 11, 2012

is there a attribute (like GenerateScriptType) that will serialize a custom type directly

I looked up the way asp.net ajax does it on a page ( with scriptmanager on page + method returning my type), and what it does is pretty crude.
I was able to replicate it in my control by outputing the following javascript to the browser:

Type.registerNamespace('ns.App');
if (typeof(ns.App.MyType) === 'undefined') {
ns.App.MyType=gtc('ns.App.MyType');
ns.App.MyType.registerClass('ns.App.MyType');
}

(all it does is create a new Object() under that hierarchy and assisngs it a __namespace property.. that will later tell the de-serializer which type to instantiate with any properties that might be supplied)

this should work fine.. but hopefully there is a attribute that will make asp.net ajax framework generate this automatically.... ?

No comments:

Post a Comment