Enum和ViewState的相互转换
Public Property CurrentPage() As PageType
Get
If Not ViewState("CurrentPage") Is Nothing Then
Dim enumType As Type = GetType(PageType)
Dim enumIndex As Integer = CInt(ViewState("CurrentPage"))
Return DirectCast([Enum].ToObject(enumType, enumIndex), PageType)
End If
Return PageType.SeletionPage
End Get
Set(ByVal value As PageType)
ViewState("CurrentPage") = CType(value, Integer)
End Set
End Property
Get
If Not ViewState("CurrentPage") Is Nothing Then
Dim enumType As Type = GetType(PageType)
Dim enumIndex As Integer = CInt(ViewState("CurrentPage"))
Return DirectCast([Enum].ToObject(enumType, enumIndex), PageType)
End If
Return PageType.SeletionPage
End Get
Set(ByVal value As PageType)
ViewState("CurrentPage") = CType(value, Integer)
End Set
End Property
本作品采用 知识共享署名-非商业性使用 2.5 中国大陆许可协议进行许可。 |