XmlForm.FormState 属性
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
获取一个对 System.Collections.IDictionary 类型的属性包的引用,启用浏览器功能的表单可以使用该属性包来维护服务器上各个会话的状态信息。
public:
abstract property System::Collections::IDictionary ^ FormState { System::Collections::IDictionary ^ get(); };
public abstract System.Collections.IDictionary FormState { get; }
member this.FormState : System.Collections.IDictionary
Public MustOverride ReadOnly Property FormState As IDictionary
属性值
一个 IDictionary ,它包含表单代码的声明节中定义的任何用户定义的状态变量。
示例
以下代码示例演示一个设计模式,用于在 FormCode 类(在 InternalStartup 方法之前,且用作计数器)的声明部分创建状态变量。 下面的代码示例验证 _Counter 变量是否为 null 引用 (Visual Basic) 中 Nothing,然后再返回 值以避免 FormState 数组未初始化的错误。
private int _Counter
{
get
{
if(FormState["_Counter"] != null)
{
return (int) FormState["_Counter"];
}
else
{
return 0;
}
}
set
{
FormState["_Counter"] = value;
}
}
Private Property _Counter As Integer
Get
If(FormState("_Counter") != null) Then
_Counter = DirectCast(FormState("_Counter"), Integer)
Else
_Counter = 0
End If
End Get
Set
FormState("_Counter") = value
End Set
End Property
注解
可以无限制访问此成员。
可以通过 Microsoft InfoPath Filler 或 Web 浏览器内打开的表单中运行的代码访问此类型或成员。