473,396 Members | 1,722 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,396 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 1176
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
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
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...

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.