I wrote a custom serializer in order to get as objects with properties
(columns of the datarow, names of the items in an enumeration).
The code is the following only for the Serialize method (the rest is
the same as the original AJAX converter for DataRow):
public override string Serialize (object o)
{
StringBuilder sb;
DataRow row;
bool b;
if(!(o is DataRow)) { throw new NotSupportedException (); }
sb = new StringBuilder();
row = (DataRow) o;
b = true;
sb.Append ("{");
foreach (DataColumn column in row.Table.Columns)
{
if (b){ b = false; }
else { sb.Append (","); }
sb.Append (string.Format ("{0}:{1}",
JavaScriptSerializer.Serialize
(column.ColumnName), JavaScriptSerializer.Serialize (row [column])));
}
sb.Append ("}");
return sb.ToString ();
}
with this configuration in the web.config in the ajaxNet settings for
the json converters:
<jsonConverters>
<remove type="AjaxPro.DataRowConverter,AjaxPro.2" />
<add
type="esanchezfo.Tool.Web.Ajax.DataRowConverter,esanchezfo.Tool.Web" />
</jsonConverters>
The goal is to get as instance of DataRow in client some like:
var dataRow = {ColumnA:ValA, ColumnB: ValB}
then the property: dataRow.ColumnA has the value ValA
The same code with a few changes could be used for an enumeration.
However the result in the client is for the object returned an object
with property value null.
For instance, when call:
GetUser () { ... }
GetUser_Callback (dr_User) { // dr_User is an object, but dr_User.value
is null
Please have in mind this suggest about the code, and please tell us how
to implement the replace of the default JSON converters correctly.
Thanks.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ajax.NET Professional" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/ajaxpro
The latest downloads of Ajax.NET Professional can be found at
http://www.ajaxpro.info/
Don't forget to read my blog at http://weblogs.asp.net/mschwarz/
-~----------~----~----~----~------~----~------~--~---