# SetDirty Method

Sets theIsDirty property on the XDocument object to a Boolean value that indicates whether the data in a Microsoft Office InfoPath 2003 form has been modified since it was last saved.

expression.SetDirty(ByVal vfIsDirty As Boolean)

expression Required. An expression that returns a reference to an XDocument object.

vfIsDirty Required Boolean. Specifies whether the form is to be marked as unmodified or not.

## Security Level

2: Can be accessed only by forms running in the same domain as the currently open form, or by forms that have been granted cross-domain permissions.

## Remarks

The SetDirty method can be used from the OnSubmitRequest event handler to force a document to be marked as unchanged. InfoPath will therefore not request the user to save the form when it is closed.

The SetDirty method can also be used from the OnSaveRequest event handler to programmatically mark the form as changed or unchanged since it was last saved.

Note This object model member is not supported when the Disable Service Pack features option on the Advanced tab of the Options dialog box in InfoPath is selected or when Microsoft Office 2003 Service Pack 1 or later is not installed. Any form that implements this object model member in its code will generate an error message if it is opened in InfoPath when service pack features are disabled or unavailable.

## Example

In the following example, the IsDirty property of the current form is set to False so that InfoPath will not prompt the user to save the form when it is closed.

    XDocument.SetDirty(false);

©2003-2004 Microsoft Corporation. All rights reserved. Permission to copy, display and distribute this document is available at: http://msdn.microsoft.com/library/en-us/odcXMLRef/html/odcXMLRefLegalNotice.asp