473,473 Members | 2,243 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

globalization

still trying to set variables for use in all sub-pages...

thought I'd found the solution with global.ascx:
Application("connstring") = "...";
Session("UserID") = 0;

well it turns out the application and session objects are not pure system
int/string type of objects so that each time I access them I have to use a
cast eg
if ((int) Session("UserID") >0) ...

I think this is not a good way so how oh how can I just add constants to the
global class and then
if (global.UserID >0) ...

???
Nov 19 '05 #1
3 1692
hmm sorry I've learned that "globalization" refers to something else than
using variables set "globally" in global.ascx

still... please can someone help me on this so easy thing: to set a static
variable in global.ascx to use in all sub-pages?!

"Daves" <db****@simnet.is> wrote in message
news:O6**************@TK2MSFTNGP14.phx.gbl...
still trying to set variables for use in all sub-pages...

thought I'd found the solution with global.ascx:
Application("connstring") = "...";
Session("UserID") = 0;

well it turns out the application and session objects are not pure system
int/string type of objects so that each time I access them I have to use a
cast eg
if ((int) Session("UserID") >0) ...

I think this is not a good way so how oh how can I just add constants to
the global class and then
if (global.UserID >0) ...

???

Nov 19 '05 #2
Variables/Classes are stored as "Objects" in your Session.
so you should do something like this
if (Session("UserID") is null) then
Session("UserID") = 100
Else
' session is already set to use it you have to cast it to an int
dim p as int = (Int) Session("UserID")
End if
I "think" this code will work. Basically you need to check to see if
the object exists. If it does not exist you need to initialize it to a
value.
If this does not solve your problem then try to rephrase your question
and provide more details.
Remember that Sesion Variables are specific to a user's web session
where as application are specific to the whole website.
Information about a user would be stored in a session. rmembering that
when the user is idle for more hten 20 minutes this information is
lost.
Information about the whole site woudl be stored in your Application.
This information is lost if the application is restarted for any reason
or the web server is restarted.

Nov 19 '05 #3
thx, this is true - it works by casting and I do watch out not having them
set as null.
But I still want to access the variables just as simple class (static)
properties; they are easier to access (global.UserId rather than (int)
Session("UserID")) and as I understand the case they are easier load on the
server

"re****@community.nospam" <ma**********@gmail.com> wrote in message
news:11*********************@g14g2000cwa.googlegro ups.com...
Variables/Classes are stored as "Objects" in your Session.
so you should do something like this
if (Session("UserID") is null) then
Session("UserID") = 100
Else
' session is already set to use it you have to cast it to an int
dim p as int = (Int) Session("UserID")
End if
I "think" this code will work. Basically you need to check to see if
the object exists. If it does not exist you need to initialize it to a
value.
If this does not solve your problem then try to rephrase your question
and provide more details.
Remember that Sesion Variables are specific to a user's web session
where as application are specific to the whole website.
Information about a user would be stored in a session. rmembering that
when the user is idle for more hten 20 minutes this information is
lost.
Information about the whole site woudl be stored in your Application.
This information is lost if the application is restarted for any reason
or the web server is restarted.

Nov 19 '05 #4

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

Similar topics

1
by: Dejan Vesic | last post by:
I found nasty "documentation" bug; ms-help://MS.VSCC/MS.MSDNVS/cpref/html/frlrfsystemglobalizationcultureinfoclasstopic.htm claims that proper culture info name for Serbian (Cyrillic) - Serbia...
3
by: Xavier MT | last post by:
Hi, I have a site that has some text in spanish and it doesn't display well, for example with a ñ it displays some weird boxes, can anyone help me or point me to some help
0
by: FM | last post by:
Hi, I use the following code to set the current culture. If Not IsNothing(Session("language")) Then System.Threading.Thread.CurrentThread.CurrentCulture = New...
11
by: Cor Ligthert | last post by:
Hello everybody, Jay and Herfried are telling me every time when I use CDate that using the datetime.parseexact is always the best way to do String to datetime conversions. They don't tell why...
0
by: SimonZ | last post by:
Hi, I set the globalization settings to: <globalization requestEncoding="utf-8" responseEncoding="utf-8" fileEncoding="utf-8" culture="en-GB" uiCulture="en" /> Everything is just fine, only...
1
by: Mark | last post by:
Assume you have a simple HTML form that submits its form results to a .aspx page. The receiving .aspx page processes the values sent by the form. If the form data contains an accented character...
2
by: jason | last post by:
DOTNET 2.0 VS 2005. My client is saying August 13,2006.. julian date should equal 225. Here's what I'm doing: <%@ Import Namespace="system.globalization" %> <script language="VB"...
1
by: =?Utf-8?B?S3Jpc2huYQ==?= | last post by:
Hi, I am krishna in India.I developed Asp.net application the default culture settings is <globalization culture="en-US" uiCulture="en-US"/>.I need change globalization settings for UK.How to...
2
by: Terry Olsen | last post by:
I'm a bit confused on how to make my app work in all cultures, particularly with parsing the date out of a string. I read dates from different web sites. The formats I've run into include...
0
by: Sparkiee | last post by:
Hi, A lil bit of help required from you guys, I am trying to make a windows service that will also focus on globalization, the problem i am facing is when i am trying to put globalization code in...
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,...
1
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...
1
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...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.