_ButtonEventSink_Event.OnClick event

Office 2013 and later

Occurs when a Button control is clicked within a view in a Microsoft InfoPath form.

Namespace:  Microsoft.Office.Interop.InfoPath.SemiTrust
Assembly:  Microsoft.Office.Interop.InfoPath.SemiTrust (in Microsoft.Office.Interop.InfoPath.SemiTrust.dll)

event _ButtonEventSink_OnClickEventHandler OnClick

This event handler does not allow users to cancel an operation.

NoteNote

The OnClick event for the InfoPath button control is the only control event that is supported.

In the following example, the OnClick event handler is used to show the value of my:field1 in an message box:

[InfoPathEventHandler(MatchPath="btnAlert", EventType=InfoPathEventType.OnClick)]
public void btnAlert_OnClick(DocActionEvent e)
 {
  IXMLDOMNode field1;
  field1 = thisXDocument.DOM.selectSingleNode(@"/my:myFields/my:field1");
  thisXDocument.UI.Alert(field1.text);
 }
Show: