Ur first question didn't make much sense...lemme give you an example:
public class Customer
private _id as integer
private _name as string
public property Id as integer
get
return _id
end get
set
_id = value
end set
end property
public property Name as string
get
return _name
end get
set
_name = value
end set
end property
public shared function Custom GetCurrentCustomer()
if HttpContext.Current == null then
throw new Excetion("This method can only be called from a
web-context')
end if
if HttContext.Current.Session("currentCustomer") is nothing then
'return nothing, throw an excetion? create a new "anonymous custom"
....depends on ur business rules
end if
return ctype(HttpContext.Current.Session("currentCustomer "), Customer)
end function
public shared sub SetCurrentCustomer(customer as Customer)
if HttpContext.Current == null then
throw new Excetion("This method can only be called from a
web-context')
end if
HttpContext.Current.Session("currentCustomer") = customer
end sub
end class
you can then do, in your pages:
subAddCustomer_Click(...)
dim customer as New Customer()
customer.Id = 23
customer.Name = "Frank"
customer.Save()
Customer.SetCurrentCustomer(customer)
end sub
and you could access that custom as:
dim customer as Customer =Customer.GetCurrentCustomer()
you declare the customer variable where you need it..it's impossible to
answer that question without more insight
No, you don't have to use that syntax..you can pull the customer out of the
session and then modify the properties. These are all references, so if you
update a local variable, it'll update the session (assuming the local
variable was assigned from the session). In my example above, I've hidden
the session access in shared members to further encapsulate the logic.
Karl
--
http://www.openmymind.net/ http://www.fuelindustries.com/
"Shlomi" <sh*****@gmail.com> wrote in message
news:11**********************@u72g2000cwu.googlegr oups.com...
Hello,
I'm new at oop.
This is how I was storing customer info and used it in the application
in the past:
Session("CustomerName")="Bob"
Session("CustomerId")="55"
Now I created a customer class and I want to use this syntax:
Customer.CustomerName="Bob"
Customer.CustomerId ="55"
My questions:
===========
1. What between the Customer variable object and session object?
2. Where do I declare the Customer variable? What scoop? Pulic?
3. Do I have to use the syntax:
Session("Customer")=Customer , and then:
Session("Customer").CustomerName="Bob" ?
4. Where can I find more info about oop storing and retrieving
(sessions info) issues?
Thank you!!