1

I have Visual Studio 2017 and InfoPath 2013 installed currently and was investigating the custom code options for Infopath and it states that I need to install VS 2012. Is it possible to get Infopath to work with the newer version of VS or do I need to install 2012?

1

One option would be to use "XmlFormView" class to embed the InfoPath form in a custom .aspx page. Then it's possible to access the values in the code behind using VS2017.

The XmlFormView object and its associated members are used to display InfoPath forms in a Web browser. No additional components are necessary on the desktop computer except a Web browser in order to open and fill out a form based on a browser-enabled form template.

InfoPath Forms Services uses the XmlFormView control to display forms based on form templates designed in Microsoft InfoPath so that they are browser-compatible.

EX:

In .aspx page

<%@ Register Assembly="Microsoft.Office.InfoPath.Server, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c"
    Namespace="Microsoft.Office.InfoPath.Server.Controls" TagPrefix="cc1" %>
<cc1:XmlFormView ID="XmlFormViewCtrl" runat="server" />

In code behind

//set the form URL
XmlFormViewCtrl.XsnLocation = "http://siteUrl/FormTemplates/Form1.xsn";

//Retrieve values
XPathNavigator myNav = this.MainDataSource.CreateNavigator();
XPathNavigator field1= myNav.SelectSingleNode("/my:myFields/my:field1", this.NamespaceManager);
string fieldValue = field1.Value;

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.