D
DesCF
I'm working through some vb2005 code examples only I am doing them in a
web form rather than a visual basic form. I have run into the problem
where the module level variable loses its value (an array in this case).
I have solved the problem by putting the word <Serializable()> before a
Public Structure and by including the code below on the web form. Beacuse
I happen to have solved the problem this way I wll tend to do it this way
in future. My question is this the only or indeed the best way of solving
the problem ?
Private Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)
Handles Me.Load
If (Me.ViewState("arrayListInViewState") IsNot Nothing) Then
objCustomers = CType(Me.ViewState("arrayListInViewState"), ArrayList)
End If
End Sub
Protected Sub Page_PreRender(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Me.PreRender
'Save PageArrayList before the page is rendered.
Me.ViewState.Add("arrayListInViewState", objCustomers)
End Sub
web form rather than a visual basic form. I have run into the problem
where the module level variable loses its value (an array in this case).
I have solved the problem by putting the word <Serializable()> before a
Public Structure and by including the code below on the web form. Beacuse
I happen to have solved the problem this way I wll tend to do it this way
in future. My question is this the only or indeed the best way of solving
the problem ?
Private Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)
Handles Me.Load
If (Me.ViewState("arrayListInViewState") IsNot Nothing) Then
objCustomers = CType(Me.ViewState("arrayListInViewState"), ArrayList)
End If
End Sub
Protected Sub Page_PreRender(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Me.PreRender
'Save PageArrayList before the page is rendered.
Me.ViewState.Add("arrayListInViewState", objCustomers)
End Sub