_XDocumentEventSink2_Event.OnSaveRequest 事件

定义

在从 Microsoft InfoPath 用户界面或使用 Save()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 

事件类型

示例

[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;
}

注解

ReturnStatus如果 对象的 属性SaveEventObject设置为 false,InfoPath 将取消保存操作。 如果 OnSaveRequest 事件的代码中发生错误,InfoPath 将忽略该错误,并依赖于 对象的 ReturnStatus 属性 SaveEventObject 。如果未显式设置 ReturnStatus 属性,则使用默认值 false

当 InfoPath 窗体关闭时,IsCancelledReturnStatus 属性与 属性结合使用。 如果文档中有尚未保存的更改,并且用户取消了保存操作,则可将 IsCancelled 属性设置为 true 以便关闭 InfoPath。

适用于