473,405 Members | 2,445 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,405 software developers and data experts.

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 1691
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: 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: 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
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,...
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
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...
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.