425-882-1032 info@3sharp.com

Microsoft Office InfoPath 2007 supports parameters for browser forms. This functionality can make form solutions more dynamic and requires only a small amount of code. Within the Loading event of the form template, the TryGetValue method is needed for each parameter value that is being passed. Then, the appropriate fields in the form file can be set accordingly. The following C# code sample shows how the building permit application solution can be extended with a LotNumber parameter.

public void FormEvents_Loading(object sender, LoadingEventArgs e)
{
    string lotNumber = string.Empty;
    try
    {
        e.InputParameters.TryGetValue("LotNumber", out lotNumber);
    }
    catch (Exception ex)
    {
        lotNumber = ex.Message.ToString();
    }
    finally
    {
        MainDataSource.CreateNavigator().SelectSingleNode("//my:LotNumber", NamespaceManager).SetValue(lotNumber);
    }
}

In this example, the LotNumber value is passed to the form from the browser URL. It is also worth noting that the parameter names are case-sensitive, as shown in the following figure: