Book Image

SharePoint 2013 WCM Advanced Cookbook

By : JOHN CHAPMAN
Book Image

SharePoint 2013 WCM Advanced Cookbook

By: JOHN CHAPMAN

Overview of this book

Table of Contents (19 chapters)
SharePoint 2013 WCM Advanced Cookbook
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

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.

  5. With the Button control selected, click on Custom Code by navigating to CONTROL TOOLS | PROPERTIES in the Properties section. Selecting Custom Code will automatically start Visual Studio and create the project for the InfoPath form template. It will...