Adding custom .NET code to an InfoPath form

The Microsoft Visual Studio Tools for Applications allows code-based customization of documents in Microsoft Office. This has replaced the older Visual Basic for Applications (VBA) methodology for using custom code in Microsoft Office.

In this recipe, we will add custom code that sets the value of a field when a button is clicked.

How to do it...

Follow these steps to add custom .NET code to an InfoPath form:

  1. Create a new form template or open an existing one in Microsoft InfoPath Designer 2013.
  2. Add a Text Box control to the form template and give it an appropriate name, such as currentDate.
  3. Add a Button control to the form template and give it an appropriate label, such as Get Date.
  4. Save the form template. ...

Get SharePoint 2013 WCM Advanced Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.