ScriptIgnoreAttribute Class
Specifies that JavaScriptSerializer will not serialize the public property or public field. This class cannot be inherited.
Assembly: System.Web.Extensions (in System.Web.Extensions.dll)
If you apply ScriptIgnoreAttribute to a public property or public field of a class, then JavaScriptSerializer ignores, or skips, the member when serializing an instance of the class to JavaScript Object Notation (JSON) format.
The ScriptIgnoreAttribute will have no effect if the ResponseFormat property is set to Xml. If you want to have the same behavior when serializing to XML format, XmlIgnoreAttribute should be applied to the property or field instead. This is because the class will be serialized by using XmlSerializer instead of JavaScriptSerializer.
You can also apply both ScriptIgnoreAttribute and XmlIgnoreAttribute to a property or field. In this case, the property or field will be ignored for JSON and XML response formats.
For more information about how to use attributes, see Extending Metadata Using Attributes.
The following example demonstrates how to apply ScriptIgnoreAttribute to the Comment field in the custom class named Group. This instructs JavaScriptSerializer to ignore the field when serializing an instance of the class to JSON format.
- AspNetHostingPermission
for operating in a hosted environment. Demand value: LinkDemand. Associated enumeration: AspNetHostingPermissionLevel::Minimal
Windows 7, Windows Vista, Windows XP SP2, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003
The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.