This topic has not yet been rated - Rate this topic

XmlForm.FormState property

This documentation is preliminary and is subject to change.

Gets a reference to a property bag of type System.Collections.IDictionary that browser-enabled forms can use to maintain state information across sessions on the server.

Namespace:  Microsoft.Office.InfoPath
Assembly:  Microsoft.Office.InfoPath (in Microsoft.Office.InfoPath.dll)
public abstract IDictionary FormState { get; }

Property value

Type: System.Collections.IDictionary
An IDictionary that contains any user-defined state variables that were defined in the declarations section of the form code.

This member can be accessed without restrictions.

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

The following code example shows a design pattern for creating a state variable in the declarations section of the FormCode class (before the InternalStartup method) that functions as a counter. The following code example verifies that the _Counter variable is null before returning the value to avoid errors where the FormState array was not initialized.

private int _Counter
{
   get
   {
      if(FormState["_Counter"] != null)
      {
         return (int) FormState["_Counter"];
      }
      else
      {
         return 0;
      }
   }
   set
   {
      FormState["_Counter"] = value;
   }
}
Did you find this helpful?
(1500 characters remaining)

Community Additions

ADD
© 2013 Microsoft. All rights reserved.