Well, nobody else is answering this. This really isn't an answer, but the comment field is a little small.
I coded up a stupid little example, which at least looks like it works. What am I missing, what am I not doing that you are?
It causes this to be output to the page:
Sys.Application.add_init(function() {
$create(NS, {"d1":{"t1":{"j1":1,"s1":{"Capacity":16,"MaxCapacity":2147483647,"Length":1}}}}, null, null, $get("__Page"));
});
Sys.Application.initialize();
And here's the source:
using System;
using System.Web;
using System.Web.UI;
using System.Collections.Generic;
using System.Text;
namespace Debuggin
{
public class Test
{
public int j1 = 1;
private int j2 = 2;
public StringBuilder s1 = new StringBuilder("x");
public override string ToString()
{
return "Test obj";
}
}
public partial class _Default : System.Web.UI.Page, IScriptControl
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected override void OnInit(EventArgs e)
{
Page.Init += delegate(object sender, EventArgs e_Init)
{
if (ScriptManager.GetCurrent(Page) == null)
{
ScriptManager sMgr = new ScriptManager();
Page.Form.Controls.AddAt(0, sMgr);
}
};
base.OnInit(e);
}
protected override void OnPreRender(EventArgs e)
{
base.OnPreRender(e);
ScriptManager.GetCurrent(Page).RegisterScriptControl(this);
ScriptManager.GetCurrent(Page).RegisterScriptDescriptors(this);
}
#region IScriptControl Members
public System.Collections.Generic.IEnumerable<ScriptDescriptor> GetScriptDescriptors()
{
ScriptControlDescriptor descriptor = new ScriptControlDescriptor("NS", this.ClientID);
Dictionary<string, object> d = new Dictionary<string, object>();
d.Add("t1", new Test());
descriptor.AddProperty("d1", d);
return new ScriptDescriptor[] { descriptor };
}
public System.Collections.Generic.IEnumerable<ScriptReference> GetScriptReferences()
{
return new ScriptReference[]{};
}
#endregion
}
}