473,769 Members | 6,799 Online
Bytes | Software Development & Data Engineering Community
+ 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("co nnstring") = "...";
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 1707
hmm sorry I've learned that "globalizat ion" 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******** ******@TK2MSFTN GP14.phx.gbl...
still trying to set variables for use in all sub-pages...

thought I'd found the solution with global.ascx:
Application("co nnstring") = "...";
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("UserI D") 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****@communi ty.nospam" <ma**********@g mail.com> wrote in message
news:11******** *************@g 14g2000cwa.goog legroups.com...
Variables/Classes are stored as "Objects" in your Session.
so you should do something like this
if (Session("UserI D") 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
3850
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 is "Cy-sr-SP" but if you try this, you will get "Culture name Cy-sr-SP is not supported" exception. If you set up culture info via System.Globalization.CultureInfo(0x081A) and than retrieve
3
1434
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
349
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 System.Globalization.CultureInfo(Session("language").ToString) End If
11
7250
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 only that I have to listen to them because they know it better. They told also that in a business situation it is better to use datetime.parseexact for changing cultures and not to use the globalization setting. I did not give them this sample,...
0
1166
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 number formatting is not what I want. The number formating is for en_GB culture: dot for decimal symbol and comma
1
1747
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 (ex., Ángel with an accent over "A"), the REQUEST object appears to loose the globalization, and nukes any extended ascii characters. Is there a way to avoid this? In the examples below, the resulting string is "ngel", without the A and accent....
2
3142
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" runat="server">
1
2375
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 modify the web.config file ?.What is coorect culture for UK and India?. Pls help Thanks in Advance Regards T.A.Krishna
2
5119
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 'yyyy.mm.dd', 'dd/mm/yyyy', 'yyyy-mm-dd', 'dd-mmm-yyyy'. I'm using the following code to parse the date, which has worked for a lot of Regions but not all, such as Germany. Dim CI As System.Globalization.CultureInfo CI =...
0
3048
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 app.config the windows service throws an error its probably because of using the <system.webin app.config that contains the globalization parameters, copied and pasted from one of my asp.net website where i already used the globalization and i...
0
9590
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9424
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10223
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10000
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9866
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8879
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5448
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3968
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 we have to send another system
2
3571
muto222
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.