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