3 March 2013

C # programming in the Infopath 2010 forms


Infopath forms can give better look and feel for the user interface in SharePoint.
It is recommended to use Infopath for lesser complex user interface and to use minimal coding in the Infopath forms.
How ever c# programming is possible in Infopath forms for the client side validation and presentation purpose or implementation of certain level of business logic.

Xpath objects are used to access the Infopath values.

Before submitting the form we can make the data   to be validated, verified or transformed using c# code. For this we need to enable Perform custom action using code in the submit options.

If we have VSTA (Visual Studio Tools for Applications) and .net framework 3.1 SP1
We can program in Infopath using c#.

The events available in the info path forms are classified as Button events, Data events and Form events. There is a limitation of browser compatibility of some of the events.

Once form is designed and authored the source code, form can be published for publishing we need to configure the form as domain trust or full trust.


Domain trust forms can be published to SharePoint as Sandboxed Solutions directly from the Infopath 2010 Designer. With Sandboxed Solutions, However SharePoint Server farm administrators can control the resources available to the code and developers cannot access resources subject to operating system security. This help Site Collection administrators can publish code with out Farm administrator approval.

Publishing a full trust form to SharePoint requires activating the solution through the SharePoint Central Administration.

From my experience I will recommend to keep InfoPath forms as simple as it can and use visual web parts for complex user interaction screens where code need to implemented.