_XDocumentEventSink2_Event.OnSubmitRequest Event

Definition

Occurs when the submit operation is invoked either from the Microsoft InfoPath user interface or by using Submit() method.

public:
 event Microsoft::Office::Interop::InfoPath::SemiTrust::_XDocumentEventSink2_OnSubmitRequestEventHandler ^ OnSubmitRequest;
event Microsoft.Office.Interop.InfoPath.SemiTrust._XDocumentEventSink2_OnSubmitRequestEventHandler OnSubmitRequest;
member this.OnSubmitRequest : Microsoft.Office.Interop.InfoPath.SemiTrust._XDocumentEventSink2_OnSubmitRequestEventHandler 
Event OnSubmitRequest As _XDocumentEventSink2_OnSubmitRequestEventHandler 

Event Type

Examples

In the following example, the OnSubmitRequest event handler is used to prevent the Submit operation if the form has not been saved.

[InfoPathEventHandler(EventType=InfoPathEventType.<span class="label">OnSubmitRequest</span>)]
public void OnSubmitRequest(DocReturnEvent e)
{
 if(thisXDocument.IsDirty || thisXDocument.IsNew)
 thisXDocument.UI.Alert("Please save this form before submitting");
else
 e.ReturnStatus = true;
}

In the following example, the OnSubmitRequest event handler is used to prevent the Submit operation if the form has not been saved.

[InfoPathEventHandler(EventType=InfoPathEventType.<span class="label">OnSubmitRequest</span>)]
public void OnSubmitRequest(DocReturnEvent e)
{
 if(thisXDocument.IsDirty || thisXDocument.IsNew)
 thisXDocument.UI.Alert("Please save this form before submitting");
else
 e.ReturnStatus = true;
}

Remarks

This event handler allows users to cancel a Submit operation.

If the ReturnStatus property of the DocReturnEventObject object is set to false, InfoPath cancels the submit operation. If an error occurs in the scripting code for the OnSubmitRequest event, InfoPath ignores it and relies on the ReturnStatus property. If the ReturnStatus property is not explicitly set, the default value of false is used.

Applies to