I'm trying to learn to use ViewState but I guess I'm a little confuse. On a logon page, I have the following:
When you user enter their username/password and choose a session that they logon, I define the following:Code:Dim vsViewState As classData.vsInfo (vsInfo is a serializable struture) Protected Sub Page_PreRender(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.PreRender Me.ViewState.Add("ViewStateData", vsViewState) End Sub
After the user logon, I want to display the username/pass & the group that they login on the next page:Code:Protected Sub btnLogon_Click(ByVal sender As Object, ByVal e As System.EventArgs) vsViewState.Username = getUserName() vsViewState.Password = getPassword() vsViewState.GroupID = getGroupID() End Sub
Code:Dim vsViewState As classData.vsInfo (vsInfo is a serializable struture) Protected Sub Page_PreRender(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.PreRender Me.ViewState.Add("ViewStateData", vsViewState) End SubCode:Public ReadOnly Property ViewStateInfo() As classData.vsInfo Get Dim vsValues As classData.vsInfo vsValues = CType(ViewState("ViewStateData"), classData.vsInfo) Return vsInfo End Get End PropertyMy groupID & username is nothing...do you know why?Code:Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load Dim groupID As String = ViewStateInfo.GroupID Dim username As String = ViewStateInfo.Username End Sub




Reply With Quote