473,413 Members | 1,811 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,413 software developers and data experts.

module level variable in web forms

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

--
Using Opera's revolutionary e-mail client: http://www.opera.com/mail/
Nov 10 '06 #1
2 1186
its reasonable is the size is modest. you are sending the data to the client
and the client is sending it back. this wil make the download and postback
of pages slower and use more bandwidth. you have to decide when its too
much.

-- bruce (sqlwork.com)

"DesCF" <de***@aol.comwrote in message news:op.tis7002nupgxg0@descstar...
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

--
Using Opera's revolutionary e-mail client: http://www.opera.com/mail/
Nov 10 '06 #2
But what do you do when it is too much ?
On Fri, 10 Nov 2006 18:10:59 -0000, bruce barker (sqlwork.com)
<b_*************************@sqlwork.comwrote:
its reasonable is the size is modest. you are sending the data to the
client
and the client is sending it back. this wil make the download and
postback
of pages slower and use more bandwidth. you have to decide when its too
much.
-- bruce (sqlwork.com)
"DesCF" <de***@aol.comwrote in message
news:op.tis7002nupgxg0@descstar...
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


--
Using Opera's revolutionary e-mail client: http://www.opera.com/mail/
Nov 11 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Bob | last post by:
Declaring a module level form object in multiple froms within a project to show another project form causes a stack overflow and other assorted errors. Can anyone help?
4
by: Bobbak | last post by:
Hello All, I was wondering if it is possible to do this; I have a form that has number of text boxes that when a button is clicked it turns into combo boxes, simply by toggling the visibility to...
8
by: Floris van Haaster | last post by:
Hi All! I have a question, i have a web application and I store some member information in a variable i declared in a module like: Public some_info_variable as string in module1.vb But...
7
by: Just Me | last post by:
I have a project that contains a usercontrol, some forms and a module. The only thing in the module is one variable that is there so that it can be used by the control and all the forms. ...
3
by: BerkshireGuy | last post by:
I have a form that contains two subforms. Both of these subforms use the same function. Rather than repeating the code, I want to be able to pass the form name to the code. Right now, its a...
2
by: tobiah | last post by:
I am making a web app, made up of many modules that all need access to some important data, like the current session data, cookies, navigation history, post/get variables, etc. I decided to go...
1
by: lemke_juergen | last post by:
Hi everyone, I define some vars and functions in a "support" module which gets called from my main app module. Using Python 2.5. I import all symbols in the support module at the top of the...
4
by: carl.dhalluin | last post by:
Hello I am completely puzzled why the following exec code does not work: mycode = "import math\ndef f(y):\n print math.floor(y)\nf(3.14)" def execute(): exec mycode execute()
6
by: dudeja.rajat | last post by:
Hi, I found on the net that there is something called module initialization. Unfortunately, there is not much information for this. However, small the information I found module initialization...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.