hello michael,

i think i found a bug in the JavaScriptSerializer class in the
SerializeCustomObject Method in conjunction with the
AjaxNonSerializableAttribute and AjaxPropertyAttribute.

When I specify the attributes on properties, they are not regarded,
since you get the customattributes from the Memberinfo of the
get-Method of the property.

The problem lies in line 171 of the JavaScriptSerializer.cs.

PropertyInfo prop = properties[i];
MethodInfo mi = prop.GetGetMethod();
if (mi.GetParameters().Length <= 0)
{
        // Bugfix, change mi.GetCustomAttributes to prop.GetCustomAttributes
        if((nsa.Length > 0 &&
prop.GetCustomAttributes(typeof(AjaxPropertyAttribute), true).Length >
0) ||
           (nsa.Length == 0 && prop.GetCustomAttributes(
typeof(AjaxNonSerializableAttribute), true).Length == 0))

You can easily recreate the problem by creating a class an specifying
the AjaxNoSerializeableAttribute on a public property. When calling the
JavaScriptSerializer.Serialize method with that object, the marked
property will still be included in the resulting JSON string.

if you have any questions or if i should email you a sample to recreate
the problem, please drop me an email.

on the other hand keep up the good work, i definetly enjoy working with
ajaxpro....

regards, hannes.


--~--~---------~--~----~------------~-------~--~----~
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/
-~----------~----~----~----~------~----~------~--~---

Reply via email to