Apllication variables in net

G

Guest

I am in the process of converting 'classic' asp to asp.net. At application
startup (global.asax) I create a prototype of table structure. Throughout my
system I copy that application prototype structure into a local variable. I
find when I make changes to that local variable they are also reflected in
the application variable. This of course defeats the purpose because
that prototype is never suppose to change, and it is never updated anywhere
in my application except in the global.asax. In the 'classic' asp version
this worked without a hitch. When I read a application variable is it
considered byref or byval?
 
S

Sharon

Hi Bill.
What you are probably doing, is to copy the reference
of the object stored in the application collection.
So any changes you make, will be performed on the
object stored in the application collection.
What you need to do, is copy the object itself.
Sharon.
 
G

Guest

all I do is:

table = application.contents("something")

make change to table

NEVER update application.contents("something")

After the above, application.contents("something") now reflects the changes
that I
made in table.

If the above is wrong could you give an example of how to accomplish what I
want to do?

Thanks !
 
S

Sharon

table (table = application.contents("something")) is just a reference
to the object stored in the application collection.
It is not a copy of the object.
You need to "deep copy" the object.
How to deep copy, depends on what Type "table" is.
Sharon.
 
G

Guest

The application variable contains a array of structures. I really appreciate
your quick responses to my questions ! It's sooooo much easier than contact
,icrosoft support!
 
S

Sharon

If the Array contains structs, which are value types, then you can use
the Array class Clone or Copy method.
See Array class documentation on how to do this.
 
G

Guest

Thank you very much ! This is of course another diviation from the way
'classic' asp works.....again. Thanks.
 
S

Sharon

Asp.net is nothing like Asp.
To really understand Asp.net, a good understanding of
object oriented is needed.
Anyway i'm happy i could help.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,902
Latest member
Elena68X5

Latest Threads

Top