2012年3月26日月曜日

returing a datatable

I'm having a problem trying to get a datatable from a CodeBehind using Pagemethods with ASP.NET Ajax Rc that was just released. The specific error is below. This code worked with the July CTP. If you have any suggestions, let me know.

System.InvalidOperationException A Circular reference was detedted while serializing an object of type System.Reflection.Module

Returning a datatable - solution

1) add reference ASP.NET 2.0 AJAX Futures December CTP DLL to solution,

2) add the following section to web. config

<

scripting>

<

webServices>

<

jsonSerialization>

<

converters>

<

addname="DataSetConverter"type="Microsoft.Web.Preview.Script.Serialization.Converters.DataSetConverter, Microsoft.Web.Preview"/>

<

addname="DataRowConverter"type="Microsoft.Web.Preview.Script.Serialization.Converters.DataRowConverter, Microsoft.Web.Preview"/>

<

addname="DataTableConverter"type="Microsoft.Web.Preview.Script.Serialization.Converters.DataTableConverter, Microsoft.Web.Preview"/>

</

converters>

</

jsonSerialization>

</

webServices>

</scripting>

3) Add ASP.NET 2.0 AJAX Futures December CTP 'PreviewScript.js' to ur solution

4) Add the Script reference ur aspx page

<asp:ScriptManagerID="ScriptManager1"runat="server"><Scripts><asp:ScriptReferencePath="PreviewScript.js"/></Scripts></asp:ScriptManager>

5) we need to change the PageMethod(in code behind page that returns DataTable) toStatic

6)in order to get the result this way( result.getItem(i).getProperty("Column name");) we need to parse

Sys.Preview.Data.DataTable.parseFromJson(result);


This doesn't work anymore in v1.0. Anyone know how to fix it?

jsonSerialization>

<

converters>

<

addname="DataSetConverter"type="Microsoft.Web.Preview.Script.Serialization.Converters.DataSetConverter, Microsoft.Web.Preview"/>

<

addname="DataRowConverter"type="Microsoft.Web.Preview.Script.Serialization.Converters.DataRowConverter, Microsoft.Web.Preview"/>

<

addname="DataTableConverter"type="Microsoft.Web.Preview.Script.Serialization.Converters.DataTableConverter, Microsoft.Web.Preview"/>

</

converters>

</

jsonSerialization>


This does work, I just forgot to download the January Futures CTP.

0 件のコメント:

コメントを投稿