470,613 Members | 1,719 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,613 developers. It's quick & easy.

need Help on a Class livetime under ASP.NET

Hi guys,

I'm using a session to save an ArrayList, so I do not read Database
everytime user reload the page or enter the site (the Data is consistent for
all entire session time when the user is on the site).

I'm using a Class called ProductBoxes and inside I have a public property
of Object type and I call from the PageLoad event

dim boxes as new ProductBoxes
boxes.ProductSession = session("something")

and it works ok, with all the subs and function of the class, so I can
populate the page with 5 boxes (images) in the way I want.

but when I raise btnLeft_OnClick HOW CAN USE A SUB UNDER my class?

Protected Sub btnMoveLeft_Click(ByVal sender As Object, ByVal e As
System.Web.UI.ImageClickEventArgs)
boxes.moveLeft()
End Sub

if I do:
dim boxes as new ProductBoxes
boxes.moveLeft()

I get an error when I use the session... because I'm creating a NEW instance
of the object and I need to use the old one, the old one have the session
with the data that I need :(

how can I do this? or all the Data in a Class as the life of a "refresh"
page? do I need to always save the data in a HiddenField so I can get it
again and populate the new instance??? but that's crazy :( isn't it?


--
Thank you in Advance.

Bruno Alexandre
(a Portuguese in Denmark)
Apr 6 '06 #1
8 1145
private boxes as ProductBoxes

sub page_load(...)
boxes = new ProductBoxes()
boxes.ProductSession = session("something")

end sub

Protected Sub btnMoveLeft_Click(...)
'you can use boxes here because it's already been created and the session
loaded in page_load
End Sub
Karl
--
http://www.openmymind.net/

"Bruno Alexandre" <br*******@filtrarte.com> wrote in message
news:eP**************@TK2MSFTNGP04.phx.gbl...
Hi guys,

I'm using a session to save an ArrayList, so I do not read Database
everytime user reload the page or enter the site (the Data is consistent
for
all entire session time when the user is on the site).

I'm using a Class called ProductBoxes and inside I have a public property
of Object type and I call from the PageLoad event

dim boxes as new ProductBoxes
boxes.ProductSession = session("something")

and it works ok, with all the subs and function of the class, so I can
populate the page with 5 boxes (images) in the way I want.

but when I raise btnLeft_OnClick HOW CAN USE A SUB UNDER my class?

Protected Sub btnMoveLeft_Click(ByVal sender As Object, ByVal e As
System.Web.UI.ImageClickEventArgs)
boxes.moveLeft()
End Sub

if I do:
dim boxes as new ProductBoxes
boxes.moveLeft()

I get an error when I use the session... because I'm creating a NEW
instance
of the object and I need to use the old one, the old one have the session
with the data that I need :(

how can I do this? or all the Data in a Class as the life of a "refresh"
page? do I need to always save the data in a HiddenField so I can get it
again and populate the new instance??? but that's crazy :( isn't it?


--
Thank you in Advance.

Bruno Alexandre
(a Portuguese in Denmark)

Apr 6 '06 #2
I can't do that... it gives me an error (I thought it worked like that)

Public Class ProductBoxes
Private _session As Object
.....

Public Property prdSession() As Object
Get
Return _session
End Get
Set(ByVal value As Object)
_session = value
End Set
End Property

and the funcion starts with

Public Sub moveLeft()
Dim listImages As ArrayList = _session
Dim listCount As Integer = listImages.Count <<<-----
Dim currentMiddleImg As Integer = CInt(_middleImg.Value)
The error points to the <<<----- line, saying
System.NullReferenceException: Object reference not set to an instance of an
object.

in other words _session does no longer have the session("something") data
any ideias?

--
Thank you in Advance.

Bruno Alexandre
(a Portuguese in Denmark)

"Karl Seguin [MVP]" <karl REMOVE @ REMOVE openmymind REMOVEMETOO . ANDME
net> escreveu na mensagem news:%2****************@TK2MSFTNGP05.phx.gbl...
private boxes as ProductBoxes

sub page_load(...)
boxes = new ProductBoxes()
boxes.ProductSession = session("something")

end sub

Protected Sub btnMoveLeft_Click(...)
'you can use boxes here because it's already been created and the session
loaded in page_load
End Sub
Karl
--
http://www.openmymind.net/

"Bruno Alexandre" <br*******@filtrarte.com> wrote in message
news:eP**************@TK2MSFTNGP04.phx.gbl...
Hi guys,

I'm using a session to save an ArrayList, so I do not read Database
everytime user reload the page or enter the site (the Data is consistent
for
all entire session time when the user is on the site).

I'm using a Class called ProductBoxes and inside I have a public property
of Object type and I call from the PageLoad event

dim boxes as new ProductBoxes
boxes.ProductSession = session("something")

and it works ok, with all the subs and function of the class, so I can
populate the page with 5 boxes (images) in the way I want.

but when I raise btnLeft_OnClick HOW CAN USE A SUB UNDER my class?

Protected Sub btnMoveLeft_Click(ByVal sender As Object, ByVal e As
System.Web.UI.ImageClickEventArgs)
boxes.moveLeft()
End Sub

if I do:
dim boxes as new ProductBoxes
boxes.moveLeft()

I get an error when I use the session... because I'm creating a NEW
instance
of the object and I need to use the old one, the old one have the session
with the data that I need :(

how can I do this? or all the Data in a Class as the life of a "refresh"
page? do I need to always save the data in a HiddenField so I can get it
again and populate the new instance??? but that's crazy :( isn't it?


--
Thank you in Advance.

Bruno Alexandre
(a Portuguese in Denmark)


Apr 6 '06 #3
I guess I'm a little unclear..but the solution might be to do:

private _session as Object
public propert prdSession() as object
get
if _session is nothing then
_session = Session("something")
end if
return _session
end get
set
_session = value
Session("something") = value
end set
end property
and always access the value via your property, and not your field..

Karl

--
http://www.openmymind.net/
http://www.fuelindustries.com/
"Bruno Alexandre" <br*******@filtrarte.com> wrote in message
news:OO**************@TK2MSFTNGP04.phx.gbl...
I can't do that... it gives me an error (I thought it worked like that)

Public Class ProductBoxes
Private _session As Object
....

Public Property prdSession() As Object
Get
Return _session
End Get
Set(ByVal value As Object)
_session = value
End Set
End Property

and the funcion starts with

Public Sub moveLeft()
Dim listImages As ArrayList = _session
Dim listCount As Integer = listImages.Count <<<-----
Dim currentMiddleImg As Integer = CInt(_middleImg.Value)
The error points to the <<<----- line, saying
System.NullReferenceException: Object reference not set to an instance of
an object.

in other words _session does no longer have the session("something") data
any ideias?

--
Thank you in Advance.

Bruno Alexandre
(a Portuguese in Denmark)

"Karl Seguin [MVP]" <karl REMOVE @ REMOVE openmymind REMOVEMETOO . ANDME
net> escreveu na mensagem news:%2****************@TK2MSFTNGP05.phx.gbl...
private boxes as ProductBoxes

sub page_load(...)
boxes = new ProductBoxes()
boxes.ProductSession = session("something")

end sub

Protected Sub btnMoveLeft_Click(...)
'you can use boxes here because it's already been created and the
session loaded in page_load
End Sub
Karl
--
http://www.openmymind.net/

"Bruno Alexandre" <br*******@filtrarte.com> wrote in message
news:eP**************@TK2MSFTNGP04.phx.gbl...
Hi guys,

I'm using a session to save an ArrayList, so I do not read Database
everytime user reload the page or enter the site (the Data is consistent
for
all entire session time when the user is on the site).

I'm using a Class called ProductBoxes and inside I have a public
property
of Object type and I call from the PageLoad event

dim boxes as new ProductBoxes
boxes.ProductSession = session("something")

and it works ok, with all the subs and function of the class, so I can
populate the page with 5 boxes (images) in the way I want.

but when I raise btnLeft_OnClick HOW CAN USE A SUB UNDER my class?

Protected Sub btnMoveLeft_Click(ByVal sender As Object, ByVal e As
System.Web.UI.ImageClickEventArgs)
boxes.moveLeft()
End Sub

if I do:
dim boxes as new ProductBoxes
boxes.moveLeft()

I get an error when I use the session... because I'm creating a NEW
instance
of the object and I need to use the old one, the old one have the
session
with the data that I need :(

how can I do this? or all the Data in a Class as the life of a "refresh"
page? do I need to always save the data in a HiddenField so I can get it
again and populate the new instance??? but that's crazy :( isn't it?


--
Thank you in Advance.

Bruno Alexandre
(a Portuguese in Denmark)



Apr 6 '06 #4
still no luck :(

but I only set boxes.prdSession one time when the page is loaded for the 1st
time...

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)
If Not Page.IsPostBack Then

boxes.image01 = imgPrd01
boxes.image02 = imgPrd02
boxes.image03 = imgPrd03
boxes.image04 = imgPrd04
boxes.image05 = imgPrd05
boxes.middleImage = middleImgNumber
boxes.prdBoxID = imgPrdName
boxes.prdDesName = prdDescName
boxes.prdDesContent = prdDescContent
boxes.prdValue = prdValue
boxes.ProductType = "BOXES"
boxes.prdSession = Session(boxes.ProductType)

boxes.presentImages()

End If
End Sub
Protected Sub btnMoveRight_Click(ByVal sender As Object, ByVal e As
System.Web.UI.ImageClickEventArgs)
boxes.moveRight()
End Sub

Protected Sub btnMoveLeft_Click(ByVal sender As Object, ByVal e As
System.Web.UI.ImageClickEventArgs)
boxes.moveLeft()
End Sub
-----------------------------------------------------

When you enter the page, everything is fine... all the 5 images are
presented the way they need to be

when you invoke the btnMoveRight_Click and it enters in the Class Sub
moveRight or moveLeft it gives an error in the second line, the line that
needs the ArrayList.count and with a little bit of code I can see that
_session no longer have the ArrayList :-(

Private _session As Object

Public Property prdSession() As Object
Get
Return _session
End Get
Set(ByVal value As Object)
_session = value
End Set
End Property

Public Sub moveLeft()
Dim listImages As ArrayList = _session
Dim listCount As Integer = listImages.Count <---------- ERROR
Dim currentMiddleImg As Integer = CInt(_middleImg.Value)
...

-----------------------------------------------------

Exception Details: System.NullReferenceException: Object reference not set
to an instance of an object.

Line 181: '_session = getAllImagesFromArray(_type)
Line 182: Dim listImages As ArrayList = _session
Line 183: Dim listCount As Integer = listImages.Count
Line 184: Dim currentMiddleImg As Integer = CInt(_middleImg.Value)
Line 185: Dim aItens As Array

Source File: E:\_Trabalhos\_Web\101. FQ Scandinavia Demos\Intercell
(VS2005)\App_Code\ProductBoxes.vb Line: 183

-----------------------------------------------------

My question is:
Why don't the class keep the _session value like it keeps for all of the
others...?
Do I need to set all values again on each event?

Because in Window Forms, the Class keep all the values since they are set
until the user get's out the application.

Thank you in Advance.

Bruno Alexandre
(a Portuguese in Denmark)
Apr 7 '06 #5
in a webform, each request is like the user opening and closing an
application - they are all served by separate threads and are stateless
(except for things like cookies and sessions). You need to move
boxes.prdSession = Session(boxes.ProductType) outside of the IF block. This
line of code needs to be executed on Postback as well - not just during the
initial hit.

Karl

--
http://www.openmymind.net/

"Bruno Alexandre" <br*******@filtrarte.com> wrote in message
news:uI**************@TK2MSFTNGP04.phx.gbl...
still no luck :(

but I only set boxes.prdSession one time when the page is loaded for the
1st time...

Protected Sub Page_Load(ByVal sender As Object, ByVal e As
System.EventArgs)
If Not Page.IsPostBack Then

boxes.image01 = imgPrd01
boxes.image02 = imgPrd02
boxes.image03 = imgPrd03
boxes.image04 = imgPrd04
boxes.image05 = imgPrd05
boxes.middleImage = middleImgNumber
boxes.prdBoxID = imgPrdName
boxes.prdDesName = prdDescName
boxes.prdDesContent = prdDescContent
boxes.prdValue = prdValue
boxes.ProductType = "BOXES"
boxes.prdSession = Session(boxes.ProductType)

boxes.presentImages()

End If
End Sub
Protected Sub btnMoveRight_Click(ByVal sender As Object, ByVal e As
System.Web.UI.ImageClickEventArgs)
boxes.moveRight()
End Sub

Protected Sub btnMoveLeft_Click(ByVal sender As Object, ByVal e As
System.Web.UI.ImageClickEventArgs)
boxes.moveLeft()
End Sub
-----------------------------------------------------

When you enter the page, everything is fine... all the 5 images are
presented the way they need to be

when you invoke the btnMoveRight_Click and it enters in the Class Sub
moveRight or moveLeft it gives an error in the second line, the line that
needs the ArrayList.count and with a little bit of code I can see that
_session no longer have the ArrayList :-(

Private _session As Object

Public Property prdSession() As Object
Get
Return _session
End Get
Set(ByVal value As Object)
_session = value
End Set
End Property

Public Sub moveLeft()
Dim listImages As ArrayList = _session
Dim listCount As Integer = listImages.Count <---------- ERROR
Dim currentMiddleImg As Integer = CInt(_middleImg.Value)
...

-----------------------------------------------------

Exception Details: System.NullReferenceException: Object reference not set
to an instance of an object.

Line 181: '_session = getAllImagesFromArray(_type)
Line 182: Dim listImages As ArrayList = _session
Line 183: Dim listCount As Integer = listImages.Count
Line 184: Dim currentMiddleImg As Integer = CInt(_middleImg.Value)
Line 185: Dim aItens As Array

Source File: E:\_Trabalhos\_Web\101. FQ Scandinavia Demos\Intercell
(VS2005)\App_Code\ProductBoxes.vb Line: 183

-----------------------------------------------------

My question is:
Why don't the class keep the _session value like it keeps for all of the
others...?
Do I need to set all values again on each event?

Because in Window Forms, the Class keep all the values since they are set
until the user get's out the application.

Thank you in Advance.

Bruno Alexandre
(a Portuguese in Denmark)

Apr 7 '06 #6
so why using Class's in ASP.NET?

what's the point to assign a value to a property inside a class? each time
the page reloads the class loose that value...

to have a "Global" variable we need to use session (if we want that value to
expire after the session.timeout) or profiles (to save the value forever -
saving it in a DB)... right? ...off course, and cookies, but I'm trying to
build a website cookieless :-)

--
Thank you in Advance.

Bruno Alexandre
(a Portuguese in Denmark)

"Karl Seguin [MVP]" <karl REMOVE @ REMOVE openmymind REMOVEMETOO . ANDME
net> escreveu na mensagem news:%2****************@TK2MSFTNGP04.phx.gbl...
in a webform, each request is like the user opening and closing an
application - they are all served by separate threads and are stateless
(except for things like cookies and sessions). You need to move
boxes.prdSession = Session(boxes.ProductType) outside of the IF block.
This line of code needs to be executed on Postback as well - not just
during the initial hit.

Karl

--
http://www.openmymind.net/

"Bruno Alexandre" <br*******@filtrarte.com> wrote in message
news:uI**************@TK2MSFTNGP04.phx.gbl...
still no luck :(

but I only set boxes.prdSession one time when the page is loaded for the
1st time...

Protected Sub Page_Load(ByVal sender As Object, ByVal e As
System.EventArgs)
If Not Page.IsPostBack Then

boxes.image01 = imgPrd01
boxes.image02 = imgPrd02
boxes.image03 = imgPrd03
boxes.image04 = imgPrd04
boxes.image05 = imgPrd05
boxes.middleImage = middleImgNumber
boxes.prdBoxID = imgPrdName
boxes.prdDesName = prdDescName
boxes.prdDesContent = prdDescContent
boxes.prdValue = prdValue
boxes.ProductType = "BOXES"
boxes.prdSession = Session(boxes.ProductType)

boxes.presentImages()

End If
End Sub
Protected Sub btnMoveRight_Click(ByVal sender As Object, ByVal e As
System.Web.UI.ImageClickEventArgs)
boxes.moveRight()
End Sub

Protected Sub btnMoveLeft_Click(ByVal sender As Object, ByVal e As
System.Web.UI.ImageClickEventArgs)
boxes.moveLeft()
End Sub
-----------------------------------------------------

When you enter the page, everything is fine... all the 5 images are
presented the way they need to be

when you invoke the btnMoveRight_Click and it enters in the Class Sub
moveRight or moveLeft it gives an error in the second line, the line that
needs the ArrayList.count and with a little bit of code I can see that
_session no longer have the ArrayList :-(

Private _session As Object

Public Property prdSession() As Object
Get
Return _session
End Get
Set(ByVal value As Object)
_session = value
End Set
End Property

Public Sub moveLeft()
Dim listImages As ArrayList = _session
Dim listCount As Integer = listImages.Count <---------- ERROR
Dim currentMiddleImg As Integer = CInt(_middleImg.Value)
...

-----------------------------------------------------

Exception Details: System.NullReferenceException: Object reference not
set to an instance of an object.

Line 181: '_session = getAllImagesFromArray(_type)
Line 182: Dim listImages As ArrayList = _session
Line 183: Dim listCount As Integer = listImages.Count
Line 184: Dim currentMiddleImg As Integer = CInt(_middleImg.Value)
Line 185: Dim aItens As Array

Source File: E:\_Trabalhos\_Web\101. FQ Scandinavia Demos\Intercell
(VS2005)\App_Code\ProductBoxes.vb Line: 183

-----------------------------------------------------

My question is:
Why don't the class keep the _session value like it keeps for all of the
others...?
Do I need to set all values again on each event?

Because in Window Forms, the Class keep all the values since they are set
until the user get's out the application.

Thank you in Advance.

Bruno Alexandre
(a Portuguese in Denmark)


Apr 7 '06 #7
The purpose of a class isn't to help with state - it's to help model your
business domain. Whether it's short lived or not, it can accomplish this
task very well.

In one of my earlier posts, I suggest that you implement some type of
factory to recreate the instance from the session. I still think that's the
right way to go.

public static UserBoxes
{
get
{
if (Session["Something"] != null)
{
return new Boxes();
}
return (Boxex)Session["Something"];
}
}

Karl
--
http://www.openmymind.net/
http://www.fuelindustries.com/
"Bruno Alexandre" <br*******@filtrarte.com> wrote in message
news:Ou**************@TK2MSFTNGP03.phx.gbl...
so why using Class's in ASP.NET?

what's the point to assign a value to a property inside a class? each time
the page reloads the class loose that value...

to have a "Global" variable we need to use session (if we want that value
to expire after the session.timeout) or profiles (to save the value
forever - saving it in a DB)... right? ...off course, and cookies, but I'm
trying to build a website cookieless :-)

--
Thank you in Advance.

Bruno Alexandre
(a Portuguese in Denmark)

"Karl Seguin [MVP]" <karl REMOVE @ REMOVE openmymind REMOVEMETOO . ANDME
net> escreveu na mensagem news:%2****************@TK2MSFTNGP04.phx.gbl...
in a webform, each request is like the user opening and closing an
application - they are all served by separate threads and are stateless
(except for things like cookies and sessions). You need to move
boxes.prdSession = Session(boxes.ProductType) outside of the IF block.
This line of code needs to be executed on Postback as well - not just
during the initial hit.

Karl

--
http://www.openmymind.net/

"Bruno Alexandre" <br*******@filtrarte.com> wrote in message
news:uI**************@TK2MSFTNGP04.phx.gbl...
still no luck :(

but I only set boxes.prdSession one time when the page is loaded for the
1st time...

Protected Sub Page_Load(ByVal sender As Object, ByVal e As
System.EventArgs)
If Not Page.IsPostBack Then

boxes.image01 = imgPrd01
boxes.image02 = imgPrd02
boxes.image03 = imgPrd03
boxes.image04 = imgPrd04
boxes.image05 = imgPrd05
boxes.middleImage = middleImgNumber
boxes.prdBoxID = imgPrdName
boxes.prdDesName = prdDescName
boxes.prdDesContent = prdDescContent
boxes.prdValue = prdValue
boxes.ProductType = "BOXES"
boxes.prdSession = Session(boxes.ProductType)

boxes.presentImages()

End If
End Sub
Protected Sub btnMoveRight_Click(ByVal sender As Object, ByVal e As
System.Web.UI.ImageClickEventArgs)
boxes.moveRight()
End Sub

Protected Sub btnMoveLeft_Click(ByVal sender As Object, ByVal e As
System.Web.UI.ImageClickEventArgs)
boxes.moveLeft()
End Sub
-----------------------------------------------------

When you enter the page, everything is fine... all the 5 images are
presented the way they need to be

when you invoke the btnMoveRight_Click and it enters in the Class Sub
moveRight or moveLeft it gives an error in the second line, the line
that needs the ArrayList.count and with a little bit of code I can see
that _session no longer have the ArrayList :-(

Private _session As Object

Public Property prdSession() As Object
Get
Return _session
End Get
Set(ByVal value As Object)
_session = value
End Set
End Property

Public Sub moveLeft()
Dim listImages As ArrayList = _session
Dim listCount As Integer = listImages.Count <---------- ERROR
Dim currentMiddleImg As Integer = CInt(_middleImg.Value)
...

-----------------------------------------------------

Exception Details: System.NullReferenceException: Object reference not
set to an instance of an object.

Line 181: '_session = getAllImagesFromArray(_type)
Line 182: Dim listImages As ArrayList = _session
Line 183: Dim listCount As Integer = listImages.Count
Line 184: Dim currentMiddleImg As Integer =
CInt(_middleImg.Value)
Line 185: Dim aItens As Array

Source File: E:\_Trabalhos\_Web\101. FQ Scandinavia Demos\Intercell
(VS2005)\App_Code\ProductBoxes.vb Line: 183

-----------------------------------------------------

My question is:
Why don't the class keep the _session value like it keeps for all of the
others...?
Do I need to set all values again on each event?

Because in Window Forms, the Class keep all the values since they are
set until the user get's out the application.

Thank you in Advance.

Bruno Alexandre
(a Portuguese in Denmark)



Apr 7 '06 #8
got it :)

Thank you for the help, and... nice Blog :)

--
Thank you in Advance.

Bruno Alexandre
(a Portuguese in Denmark)

"Karl Seguin [MVP]" <karl REMOVE @ REMOVE openmymind REMOVEMETOO . ANDME
net> escreveu na mensagem news:OQ**************@TK2MSFTNGP05.phx.gbl...
The purpose of a class isn't to help with state - it's to help model your
business domain. Whether it's short lived or not, it can accomplish this
task very well.

In one of my earlier posts, I suggest that you implement some type of
factory to recreate the instance from the session. I still think that's
the right way to go.

public static UserBoxes
{
get
{
if (Session["Something"] != null)
{
return new Boxes();
}
return (Boxex)Session["Something"];
}
}

Karl
--
http://www.openmymind.net/
http://www.fuelindustries.com/
"Bruno Alexandre" <br*******@filtrarte.com> wrote in message
news:Ou**************@TK2MSFTNGP03.phx.gbl...
so why using Class's in ASP.NET?

what's the point to assign a value to a property inside a class? each
time the page reloads the class loose that value...

to have a "Global" variable we need to use session (if we want that value
to expire after the session.timeout) or profiles (to save the value
forever - saving it in a DB)... right? ...off course, and cookies, but
I'm trying to build a website cookieless :-)

--
Thank you in Advance.

Bruno Alexandre
(a Portuguese in Denmark)

"Karl Seguin [MVP]" <karl REMOVE @ REMOVE openmymind REMOVEMETOO . ANDME
net> escreveu na mensagem news:%2****************@TK2MSFTNGP04.phx.gbl...
in a webform, each request is like the user opening and closing an
application - they are all served by separate threads and are stateless
(except for things like cookies and sessions). You need to move
boxes.prdSession = Session(boxes.ProductType) outside of the IF block.
This line of code needs to be executed on Postback as well - not just
during the initial hit.

Karl

--
http://www.openmymind.net/

"Bruno Alexandre" <br*******@filtrarte.com> wrote in message
news:uI**************@TK2MSFTNGP04.phx.gbl...
still no luck :(

but I only set boxes.prdSession one time when the page is loaded for
the 1st time...

Protected Sub Page_Load(ByVal sender As Object, ByVal e As
System.EventArgs)
If Not Page.IsPostBack Then

boxes.image01 = imgPrd01
boxes.image02 = imgPrd02
boxes.image03 = imgPrd03
boxes.image04 = imgPrd04
boxes.image05 = imgPrd05
boxes.middleImage = middleImgNumber
boxes.prdBoxID = imgPrdName
boxes.prdDesName = prdDescName
boxes.prdDesContent = prdDescContent
boxes.prdValue = prdValue
boxes.ProductType = "BOXES"
boxes.prdSession = Session(boxes.ProductType)

boxes.presentImages()

End If
End Sub
Protected Sub btnMoveRight_Click(ByVal sender As Object, ByVal e As
System.Web.UI.ImageClickEventArgs)
boxes.moveRight()
End Sub

Protected Sub btnMoveLeft_Click(ByVal sender As Object, ByVal e As
System.Web.UI.ImageClickEventArgs)
boxes.moveLeft()
End Sub
-----------------------------------------------------

When you enter the page, everything is fine... all the 5 images are
presented the way they need to be

when you invoke the btnMoveRight_Click and it enters in the Class Sub
moveRight or moveLeft it gives an error in the second line, the line
that needs the ArrayList.count and with a little bit of code I can see
that _session no longer have the ArrayList :-(

Private _session As Object

Public Property prdSession() As Object
Get
Return _session
End Get
Set(ByVal value As Object)
_session = value
End Set
End Property

Public Sub moveLeft()
Dim listImages As ArrayList = _session
Dim listCount As Integer = listImages.Count <---------- ERROR
Dim currentMiddleImg As Integer = CInt(_middleImg.Value)
...

-----------------------------------------------------

Exception Details: System.NullReferenceException: Object reference not
set to an instance of an object.

Line 181: '_session = getAllImagesFromArray(_type)
Line 182: Dim listImages As ArrayList = _session
Line 183: Dim listCount As Integer = listImages.Count
Line 184: Dim currentMiddleImg As Integer =
CInt(_middleImg.Value)
Line 185: Dim aItens As Array

Source File: E:\_Trabalhos\_Web\101. FQ Scandinavia Demos\Intercell
(VS2005)\App_Code\ProductBoxes.vb Line: 183

-----------------------------------------------------

My question is:
Why don't the class keep the _session value like it keeps for all of
the others...?
Do I need to set all values again on each event?

Because in Window Forms, the Class keep all the values since they are
set until the user get's out the application.

Thank you in Advance.

Bruno Alexandre
(a Portuguese in Denmark)



Apr 7 '06 #9

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

8 posts views Thread by JustSomeGuy | last post: by
1 post views Thread by Juan Dent | last post: by
12 posts views Thread by Kira Yamato | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.