views:

63

answers:

1

I have an object that's used both on the client and server side.

GenerateScriptType(typeof(MyClass))

However, there are some fields that I don't need on the client, so my question is there any way to prevent those fields being serialized? (For example, Field2 and Field3 in MyClass)

I tried marking the fields with [NonSerialized] but they still get serialized...

    public class MyClass
    {
        public string Field1;
        public string Field2
        {
            get;
            set;
        }
        private string _field3;
        public string Field3
        {
            get
            {
                return _field3 ?? (_field3 = "lala");
            }
        }
    }

Regards,

+1  A: 

Try adding the ScriptIgnore attribute.

Stephen Kennedy
Thanks! That's exactly what I was looking for 4 months ago =p
BlueFox
You're welcome. As for the time, well, no doubt others will get here from a Google search as I did. And now they'll find an answer too! :)
Stephen Kennedy