Compartilhar via


_XDocumentEventSink2_Event.OnSaveRequest Evento

Definição

Ocorre quando a operação de salvamento é invocada da interface do usuário do Microsoft InfoPath ou usando os Save() métodos ou SaveAs(String) .

public:
 event Microsoft::Office::Interop::InfoPath::SemiTrust::_XDocumentEventSink2_OnSaveRequestEventHandler ^ OnSaveRequest;
event Microsoft.Office.Interop.InfoPath.SemiTrust._XDocumentEventSink2_OnSaveRequestEventHandler OnSaveRequest;
member this.OnSaveRequest : Microsoft.Office.Interop.InfoPath.SemiTrust._XDocumentEventSink2_OnSaveRequestEventHandler 
Event OnSaveRequest As _XDocumentEventSink2_OnSaveRequestEventHandler 

Tipo de evento

Exemplos

[InfoPathEventHandler(EventType=InfoPathEventType.<span class="label">OnSaveRequest</span>)]
public void OnSaveRequest(SaveEvent e)
 {
  if(thisXDocument.DOM.selectSingleNode("//my:field2").text == "")
   thisXDocument.UI.Alert("Field2 is empty.\nYou cannot save the form.");
  else
e.IsCancelled = e.PerformSaveOperation();
// set ReturnStatus to false if you want InfoPath
// to show an additional error message
e.ReturnStatus = true;
}
[InfoPathEventHandler(EventType=InfoPathEventType.<span class="label">OnSaveRequest</span>)]
public void OnSaveRequest(SaveEvent e)
 {
  if(thisXDocument.DOM.selectSingleNode("//my:field2").text == "")
   thisXDocument.UI.Alert("Field2 is empty.\nYou cannot save the form.");
  else
e.IsCancelled = e.PerformSaveOperation();
// set ReturnStatus to false if you want InfoPath
// to show an additional error message
e.ReturnStatus = true;
}

Comentários

Se a ReturnStatus propriedade do SaveEventObject objeto estiver definida como false, o InfoPath cancelará a operação de salvamento. Se ocorrer um erro no código do evento OnSaveRequest , o InfoPath ignorará o erro e dependerá da propriedade ReturnStatus do SaveEventObject objeto Se a propriedade ReturnStatus não estiver explicitamente definida, o valor padrão de false será usado.

A propriedade ReturnStatus funciona em conjunto com a IsCancelled propriedade quando o formulário InfoPath está fechando. Se o documento tiver alterações que não foram salvas e o usuário cancelar a operação de salvamento, a propriedade IsCancelled poderá ser definida como true para permitir que o InfoPath feche.

Aplica-se a