473,397 Members | 1,985 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,397 software developers and data experts.

Class Definition Question

Hi

I was to create a generic shared class to check for existance of
a user login id. I'm just not sure how to do this correctly.

This is what I have

Public Class User_Utility

Shared Function CheckSession() As boolean
if Session.Item("nCustID") is nothing then
CheckSession = False
else
CheckSession = True
end if
End function
What do i need to import or associate with this class
in order to access the Session object?
I tried Imports System.Web.SessionState
but that didn't work.

Oh one other question. A shared class will only check the session
in scope, not any session variable right?

Thanks in advance
Jul 21 '05 #1
3 1177
You need to use the HttpContext.Current.Session object.
This is in the System.Web namespace. Remember to add the
System.Web.dll to your references.

Tu-Thach
-----Original Message-----
Hi

I was to create a generic shared class to check for existance ofa user login id. I'm just not sure how to do this correctly.
This is what I have

Public Class User_Utility

Shared Function CheckSession() As boolean
if Session.Item("nCustID") is nothing then
CheckSession = False
else
CheckSession = True
end if
End function
What do i need to import or associate with this class
in order to access the Session object?
I tried Imports System.Web.SessionState
but that didn't work.

Oh one other question. A shared class will only check the sessionin scope, not any session variable right?

Thanks in advance
.

Jul 21 '05 #2
thanks Tu-Thach.

ydm
"Tu-Thach" <an*******@discussions.microsoft.com> wrote in message
news:01****************************@phx.gbl...
You need to use the HttpContext.Current.Session object.
This is in the System.Web namespace. Remember to add the
System.Web.dll to your references.

Tu-Thach
-----Original Message-----
Hi

I was to create a generic shared class to check for

existance of
a user login id. I'm just not sure how to do this

correctly.

This is what I have

Public Class User_Utility

Shared Function CheckSession() As boolean
if Session.Item("nCustID") is nothing then
CheckSession = False
else
CheckSession = True
end if
End function
What do i need to import or associate with this class
in order to access the Session object?
I tried Imports System.Web.SessionState
but that didn't work.

Oh one other question. A shared class will only check

the session
in scope, not any session variable right?

Thanks in advance
.

Jul 21 '05 #3
Your class can't access it AFAIK. Instead, create a Property for the class

Public Property nCustId() As string

Get

Return _nCustId

End Get

Set(ByVal Value As String)

_nCustId = Value

End Set

End Property
Then reference the property. YOu may want to set the property in the
constructor so you'll know it's set.

Public Sub New(ByVal CustomerID as String)
me.CustID = CustomerID
'or _nCustId = CustomerID
End Sub
"Z GIRL" <no***********************@comcast.net> wrote in message
news:Be********************@comcast.com...
Hi

I was to create a generic shared class to check for existance of
a user login id. I'm just not sure how to do this correctly.

This is what I have

Public Class User_Utility

Shared Function CheckSession() As boolean
if Session.Item("nCustID") is nothing then
CheckSession = False
else
CheckSession = True
end if
End function
What do i need to import or associate with this class
in order to access the Session object?
I tried Imports System.Web.SessionState
but that didn't work.

Oh one other question. A shared class will only check the session
in scope, not any session variable right?

Thanks in advance

Jul 21 '05 #4

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

Similar topics

2
by: James Ying | last post by:
Following is the complete code demonstrating the issue: ===================== > cat tt.cc #include <iostream> template <class T> class Base { public: typedef T difference_type; };
3
by: DanielBradley | last post by:
Hello all, I have recently been porting code from Linux to cygwin and came across a problem with static const class members (discussed below). I am seeking to determine whether I am programming...
3
by: Tony Johansson | last post by:
Hello! I have these two statements typedef const char *enum_txt; and enum_txt phase_tab ={"IDLE","LAUNCHING","LAUNCHED","ROLLING","BOOSTERRELEASE","SPACE"}; where in the class definition...
5
by: Andy | last post by:
Hi all, I have a site with the following architecture: Common.Web.dll - Contains a CommonPageBase class which inherits System.Web.UI.Page myadd.dll - Contains PageBase which inherits...
2
by: tony | last post by:
Hello! I'm trying to build a class library which has a class called AvestaPlantFunc. In this project building a class libray exist a class called AvestaPlantFunc. In this class is there a...
9
by: jerry.upstatenyguy | last post by:
I am really stuck on this. I am trying to write a string array containing a "word" and a "definition" to a class called Entry. Ultimately this will end up in another class called dictionary. No,...
9
by: Jess | last post by:
Hello, I was told that if I declare a static class constant like this: class A{ static const int x = 10; }; then the above statement is a declaration rather than a definition. As I've...
2
by: joe t. | last post by:
My apologies, i'm not sure how to ask this question correctly, so i'll give the examples as i go. First, i *think* my problem is described here, but i may be misunderstanding:...
6
by: webinfinite | last post by:
Hi, How to find a STL class size, for example: string. I would like to know what the size of the implementation of this class, I am not interested in the size of its object but the class itself....
15
by: akomiakov | last post by:
Is there a technical reason why one can't initialize a cost static non- integral data member in a class?
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.