Export (0) Print
Expand All

LoadingEventArgs.InputParameters property

Gets an IDictionary that contains any input parameters specified by using the /InputParameters command-line option, query parameters in a URL, or the one of the NewFromFormTemplateWithInputParameters methods.

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

public abstract IDictionary<string, string> InputParameters { get; }

Property value

Type: System.Collections.Generic.IDictionary<String, String>
An IDictionary that contains input parameters.

ExceptionCondition
InvalidOperationException

A method was called which attempted to write to the IDictionary that contains input parameters.

Input parameters consist of one or more name/value pairs separated by the ampersand (&) character that are specified when a form template is opened from the command line or a batch file using the /InputParameters command-line option. Input parameters can also be specified by using query parameters when a form template is opened from a URL.

NoteNote

While an IDictionary is normally read/write, InfoPath prevents calls to any methods that write to the IDictionary (such as the Add or Clear methods). Any attempts to make calls that write to the IDictionary returned by the InputParameters property will throw an InvalidOperationException.

This member can be accessed only by forms running in the same domain as the currently open form, or by forms that have been granted cross-domain permissions.

This type or member can be accessed from code running in forms opened in Microsoft InfoPath Filler or in a Web browser.

In the following code example, the InfoPath form template that contains the Loading event handler code is opened from the command line or a URL using the following syntax.

Command-line:

infopath.exe "C:\User Forms\DeptReport.xsn" /InputParameters "Dept=Accounting&Acct=Contoso"

URL:

http://server/sites/team/forms/DeptReport.xsn?Dept=Accounting&Acct=Contoso

Alternatively, you can open the new form and pass in input parameters from code by using the NewFromFormTemplateWithInputParameters(String, String) method of the XmlFormCollection class, the NewFromSolutionWithInputParameters(String, String) method of the ExternalApplication interface, or the NewFromSolutionWithInputParameters(Object, Object) method of the XDocumentsCollection.

NoteNote

The last two methods are designed for use from external automation code, and cannot be called from form code.

The InputParameters property is used from a Loading event handler to set the Department field value to "Accounting" and the Account field value to "Contoso" when the form is opened. The name/value pairs that specify the values can be passed as input parameters using the /InputParameters command-line option, URL input parameter, or NewFromFormTemplateWithInputParameters(String, String) method.

public void FormEvents_Loading(object sender, LoadingEventArgs e)
{
   // Be sure that the InputParameter dictionary contains
   // values before proceeding.
   if (e.InputParameters.Count != 0)
   {
      string vDept = e.InputParameters["Dept"];
      string vAcct = e.InputParameters["Acct"];

      XPathNavigator myNav = CreateNavigator();
      myNav.SelectSingleNode("/my:myFields/my:Department",
         NamespaceManager).SetValue(vDept);
      myNav.SelectSingleNode("/my:myFields/my:Account",
         NamespaceManager).SetValue(vAcct);
   }
}
Show:
© 2014 Microsoft