Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 1.0 and 1.1 > ASP.NET 1.0 and 1.1 Basics
ASP.NET 1.0 and 1.1 Basics ASP.NET discussion for users new to coding in ASP.NET 1.0 or 1.1. NOT for the older "classic" ASP 3 or the newer ASP.NET 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.0 and 1.1 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old November 16th, 2005, 04:12 AM
Authorized User
Join Date: Nov 2005
Posts: 24
Thanks: 0
Thanked 0 Times in 0 Posts
Default Problem coming while declaring global variables


I made one variable as a global variable and intialized it at the begining with one but sometime it takes nothing even though i initialized it to 1.Can anyone tell me the reason


Old November 16th, 2005, 03:46 PM
Friend of Wrox
Join Date: Nov 2003
Posts: 1,348
Thanks: 0
Thanked 5 Times in 5 Posts

If you declare a vaiable at the page level, as you say "global", it will be initalized each time the page is loaded. Use a session variable to hold a value across posts.

Old November 18th, 2005, 06:38 PM
Registered User
Join Date: Nov 2005
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts

For such thing here is a generic Solution

Create a class file.... In whatever language u want...

This class file will contain global Variable application wide.... Say name it GlobalClass.vb or .cs

Then When you are in your very first form of you application

Create an instance of that class like dim myGlobal as new GlobalClass
set all parameters. Put it into session.
create a session("global") = myGlobal

From now onwards where ever you want you can just call it as dim myGlobal as GlobalClass= session("global").

If you are looking in for performace then you have to write it into an application variable. Which can be defined in your web.config or any such places...

Hope this helps you....

Similar Threads
Thread Thread Starter Forum Replies Last Post
Declaring static variables in ASP lakshmi_annayappa ASP.NET 1.0 and 1.1 Basics 1 May 24th, 2007 06:49 AM
Global Variables in C# su C# 2 December 11th, 2006 06:18 PM
Declaring variables in ASP - advantages? crmpicco Classic ASP Basics 1 June 25th, 2005 11:17 PM
declaring variables that are not used crmpicco VB How-To 2 May 19th, 2005 04:22 PM
Global variables zarol Beginning PHP 3 May 10th, 2005 06:17 AM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.