LoadingEventArgs.InputParameters Property
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
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.
public:
abstract property System::Collections::Generic::IDictionary<System::String ^, System::String ^> ^ InputParameters { System::Collections::Generic::IDictionary<System::String ^, System::String ^> ^ get(); };
public abstract System.Collections.Generic.IDictionary<string,string> InputParameters { get; }
member this.InputParameters : System.Collections.Generic.IDictionary<string, string>
Public MustOverride ReadOnly Property InputParameters As IDictionary(Of String, String)
Property Value
An IDictionary that contains input parameters.
Exceptions
A method was called which attempted to write to the IDictionary that contains input parameters.
Examples
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.
Note: 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);
}
}
Public Sub FormEvents_Loading(ByVal sender As Object, _
ByVal e As LoadingEventArgs)
' Be sure that the InputParameter dictionary contains
' values before proceeding.
If e.InputParameters.Count <> 0 Then
Dim vDept As String = e.InputParameters("Dept")
Dim vAcct As String = e.InputParameters("Acct")
Dim myNav As XPathNavigator = CreateNavigator()
myNav.SelectSingleNode("/my:myFields/my:Department", _
NamespaceManager).SetValue(vDept)
myNav.SelectSingleNode("/my:myFields/my:Account", _
NamespaceManager).SetValue(vAcct)
End If
End Sub
Remarks
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.
Note: 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.