asp classic - ASP Session variables and array assignments -


i have question session variables , array assignments.

i have 2 dimensional array 10 rows , 20 columns. example 1 not work , example 2 works:

example 1:

session('anar')(5, 10) = 'ab' response.write '<br>the new value ' & session('anar')(5, 10) 

the new value of session('anar')(5, 10) printed empty string.

example 2:

dim localar: localar = session('anar') locarar(0)(5, 10) = 'abc' session('anar') = localar response.write '<br>the new value ' & session('anar')(5, 10) 

now update session ('anar')(5, 10) has been done.

although works, think problem session('anar') first copied localar , localar copied session('anar').

could expert tell me please if there way modify session('anar')(5, 10) without copying of session array local array?

unfortunetaly there's not. have use local arrays.

from session object (iis)

if store array in session object, you should not attempt alter elements of stored array directly. example, following script not work:

<% session("storedarray")(3) = "new value" %>

the preceding script not work because session object implemented collection. array element storedarray(3) not receive new value. instead, value indexed collection, overwriting information stored @ location.

it recommended if store array in session object, retrieve copy of array before retrieving or changing of elements of array. when finished using array, should store array in session object again, changes made saved, demonstrated in following example:

<%  'creating , initializing array  dim myarray()  redim myarray(5)  myarray(0) = "hello"  myarray(1) = "some other string"   'storing array in session object.  session("storedarray") = myarray   response.redirect("file2.asp")  %>  

Comments

Popular posts from this blog

serialization - Convert Any type in scala to Array[Byte] and back -

matplotlib support failed in PyCharm on OSX -

python - Matplotlib: TypeError: 'AxesSubplot' object is not callable -