473,386 Members | 1,798 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

OOP in asp.net Application

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!!

Apr 11 '06 #1
3 1092
You should probably be using ASP.NET 2.0 which supports Membership, Roles,
and Profiles and you should learn how to use the Profile for the example
you've given.

<%= Clinton Gallagher
"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!!

Apr 11 '06 #2
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!!

Apr 11 '06 #3
at my blog:

http://spaces.msn.com/sholliday/ 10/24/2005
i have code to store objects (entire objects) in the session variable.

it makes adding/retrieving objects much cleaner.

...

"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!!

Apr 11 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: J. Baute | last post by:
I'm caching data in the Application object to speed up certain pages on a website The main reason is that the retrieval of this data takes quite a while (a few seconds) and fetching the same data...
3
by: Amit Dedhia | last post by:
Hi I am developing a Dot net application (involving image processing) on a uni processor. It works well on my machine. I then take all my code on a multi processor, build and run the application...
6
by: orekin | last post by:
Hi There I have been trying to come to grips with Application.Run(), Application.Exit() and the Message Pump and I would really appreciate some feedback on the following questions .. There are...
20
by: Peter Oliphant | last post by:
How does one launch multiple forms in an application? Using Photoshop as an example, this application seems to be composed of many 'disjoint' forms. Yet, they all seem somewhat 'active' in...
6
by: Josef Brunner | last post by:
Hi, I published my application (VS 2005) and am now trying to install it when I get this error message. It worked before...even on a different machine. Here is the detailed description: ...
9
by: jeff | last post by:
Hi All. I realize that when my Deployed winforms application starts, Windows needs to load the .net 2 framework before control is given to my application.... Is there anyway to either ... -...
3
by: asadikhan | last post by:
Hi, I have written a windows application with a GUI (let's call it MENU). I own the code for this application and have access to it. We have another application that is a third-part windows...
2
by: Michael Kalika | last post by:
Hi, We have developed a VSTO 2005 Excel application and we would like to leverage ClickOnce deployment mechanism for distribution of this application. How can we do that? I was digging in MSDN...
0
by: Tifer | last post by:
Hello, I am building my first .Net Application. The first couple of Publish and Installs I did went fine. But after a couple of builds, I get a modal dialogue box error every time upon trying...
4
by: Dave | last post by:
I have a global.asax file with Application_Start defined and create some static data there and in another module used in the asp.net application and I realize that static data is shared amongst...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.