Partager via


ShouldSerializeDir Method

The ShouldSerializeDir method of the WebPart class returns whether the Dir property has changed from its default value.

Return Value

true if the property value has changed from the default value; otherwise, false.

Remarks

The ShouldSerializeDir method is provided because the Dir property does not have a simple default value. This method indicates whether the property has changed from its default value. You typically invoke this method if you are developing a designer for the WebPart class, or are creating your own Web Part or tool part, so that you can avoid unnecessarily persisting default values.

If you override this function, your function should return true if the corresponding property has changed from its default, or if the SerializeAll property is true. For example:

public override bool ShouldSerializeDir()
{
    return SerializeAll || defaultDir != _dir;
}

Requirements

Platforms: Microsoft Windows Server 2003

Security: Code Access Security