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:OQoPRdkWGHA.4960@TK2MSFTNGP05.phx.gbl...[color=blue]
> 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" <bruno.pub@filtrarte.com> wrote in message
> news:Ou9wG3jWGHA.2064@TK2MSFTNGP03.phx.gbl...[color=green]
>> 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:%23PHfcnjWGHA.4452@TK2MSFTNGP04.phx.gbl...[color=darkred]
>>> 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" <bruno.pub@filtrarte.com> wrote in message
>>> news:uIUw1KiWGHA.1084@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)
>>>>
>>>>
>>>
>>>[/color]
>>
>>[/color]
>
>[/color]