.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
david stephan
Gaurav Pal
Post New Web Links

Global Variables

Posted By:      Posted Date: October 11, 2010    Points: 0   Category :ASP.Net


i need to set a few global variables, and keep them all in one place. 

they are used through out the application, but will eventually all need to be changed to something else.

is it better to use a Application variable or keep them all in web.config? or does it not really matter?


View Complete Post

More Related Resource Links

Global Variables and data types

Hi, I have a small issue with the datatype problems. This is what my scenario is. I have a global variable "Qtr" declared as "Int32" datatype. Next, i have a ActiveXscript with VBScript Language. With the below piece of code. All it does, it will calculate and assign the calculated value to the global variable "Qtr". But due to some datatype conversion problem it is not displaying the Calculated value. It is showing null. But the value in the local variable is getting displayed. Can anyone figure out what the problem is all about. I have the option of taking the String datatype for the global variable but in the next step in the workflow , we have an stored procedure call i.e. an execute sql task where we will be call a stored procedure EXEC sp ? where the parameter datatype is an INT in the database. That is why i am finding problem.  I have used the work around i.e. using SSIS advanced expressions and avoided the parameter mapping and all. Function Main() 'msgbox("test") Dim Qtr Dim currentYear 'Constants qYears = 3 Qtr= (currentYear - qYears) * 10 + 4 msgbox(Qtr) msgbox("Assigning the value to the variable") DTSGlobalVariables("Qstart").Value =  Cint(Qtr) msgbox("Display Value in the variable") MsgBox(DTSGlobalVariables("Qtr").Value)      End Function Can a

Global variables between different JS files

I have two different Javascript files, A.js and B.js. I would like to make a variable available in A.js to B.js. A.js is invoked first and the coding in it just listens for events. B.js is always running and doing something. How do I share a variable defined in an A.js function for B.js to use? I have tried finding the answer in google but its taking forever to find a pertinent scenario.

Using Global.asax to Set Session Variables Pulled From SQLServer

I have a custom class that pulls user information from a SQL Server table. Now that I'm expanding the site from a single page to others. I want to shift the code to the Session_Start event so that the information is always loaded when the site is accessed. How do I call my custom code from global.asax since its script and not a class. 

Page level global variables --- *always* bad style?


Creating an interface that we'll use internally to view and modify contents of a database.  The page uses the Wizard Control and a dropdown list to determine which clients information to display in the Wizard.

Current, I have a page level variable like this:

public static String selectedclient;

In this way, I can easily preserve which client is selected from the dropdown list between postbacks.  As it is, the program works fine.  The functionality is fulfilled.  I just keep reading that such public static page level variables are a bad idea, and that it has something to do with multithreading.  However, I've yet to see a problem or have any issues.

I really want to do this program "right" (good style), as this finished product will be used for years.  Is it going to come back to haunt me in the future if I leave it like it is?  If I need to change it, what would be a good way to preserve the same functionality?

One thing I'm thinking is that, any place where I need the selectedclient information, I could just use ClientDDList.SelectedValue.ToString().  But before I go and replace every selectedclient with ClientDDL.SelectedValue.ToString(), I'd like some advice on this issue.


Global Exception Handling with ASP.NET

After your global exception handler has done its work, you'll want to redirect the users of your website to a friendly page that tells them that something has gone wrong, and then provide them with customer support information as well as a link back to your web application's home page.

Temporary tables in SQL Server vs. table variables

When writing T-SQL code, you often need a table in which to store data temporarily when it comes time to execute that code. You have four table options: normal tables, local temporary tables, global temporary tables and table variables. I'll discuss the differences between using temporary tables in SQL Server versus table variables.

Session and Application Variables


I have a web application in which i need to logout the user if he clicks the logout button or even if he closes his browser window. On Logout button click, i am doing session.Abandon(), but how to go about his browser window close.

Can anybody help with a code sample.

Can't read global resource in asp button


I have translated Text Ok in arabic and I have that placed in global Navig.resx file

<asp:Button ID

Can IronPython use dynamic variables?


I am building a small application that can

1. Dynamically load 2 text boxes on a web form

2. Build a logic on those textboxes in IronPython to sum them and return the result.

3. I have already built a IPY script that does some opearions on a static text boxes. How to build a script on the dynamic textboxes?

Windows With C++: X64 Debugging With Pseudo Variables And Format Specifiers


This month we explain how pseudo variables and format specifiers provide a wealth of information for use in debugging.

Kenny Kerr

MSDN Magazine December 2008

Worldly Windows: Extend The Global Reach Of Your Applications With Unicode 5.0


When using global applications, people want to communicate with others on their terms, in their own languages. Unicode 5.0 brings that ideal closer to reality.

Julie D. Allen, Michael S. Kaplan, Cathy Wissink

MSDN Magazine January 2007

Locale Hero: Enable Global Apps With Locale Builder And Windows Vista


Everything you need to know about locales in Windows Vista.

Kieran Snyder and Shawn Steele

MSDN Magazine December 2006

Custom Cultures: Extend Your Code's Global Reach With New Features In The .NET Framework 2.0


The upcoming Microsoft .NET Framework 2.0 adds a number of globalization features that address the important issues of extensibility, standards support, and migration. Here authors Michael Kaplan and Cathy Wissink explain what these features mean to your globalization effort.

Michael Kaplan and Cathy Wissink

MSDN Magazine October 2005

Go Global: Make the .NET World a Friendlier Place with the Many Faces of the CultureInfo Class


CultureInfo is a complex .NET class whose objects are used for resource loading, formatting, parsing, casing, sorting, and other conventions that change as the language, location, or writing system is changed. It can be tricky to use correctly in every situation. Here Michael Kaplan explains some common scenarios in which you will use CultureInfo and provides information about the behavior, best practices, and consequences of a wrong decision.

Michael Kaplan

MSDN Magazine March 2005

Win32 Resources: Using C++ to Programmatically Retrieve a Global Cursor's Shape and ID


Getting global cursor information is useful when developing software that drives or gathers information about other UI-based applications, including information about a remote machine. This article describes a way to programmatically identify the current cursor's ID and bitmap at any point in time. The first technique described is based on polling for information and shows how to get the handle of the current global cursor. This handle will then allow you to get information about the cursor. You can also monitor WinEvents for changes to the global cursor.

Dmitri Klementiev

MSDN Magazine October 2001

Go Global: Localizing Dynamic Web Apps with IIS 5.0 and SQL Server


The success of a database-driven international Web site depends on how well the code and localized content work together with the software on the client and server. Localizing a dynamic Web site is more complicated than localizing a static one. The use of HTML and ASP code for static and dynamic content on IIS 4.0 or 5.0, coupled with Microsoft Data Access Components (MDAC) and SQL Server, enables Web sites to support as many languages as necessary. Choosing the right character sets and code pages, the variations in the Unicode support for IIS 4.0 and 5.0, as well as ways to avoid some common pitfalls are all discussed.

Jeremy Bostron and Doug Rothaus

MSDN Magazine May 2001

ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend