Home > ASP.NET 2.0, C# > Global Variable 2nd method

Global Variable 2nd method

Thursday, 15 May, 2008 Leave a comment Go to comments

App_Code\GData.cs
using System;
using System.Data;
...
public class UserInfo
{
private static string pin;
public static string Pin
{
get { return pin; }
set { pin = value; }
}
private static string fio;
public static string Fio
{
get { return fio; }
set { fio = value; }
}
}
public class QData
{
...
public class GData
{
public static void SetUserInfoPIN(string pin)
{
UserInfo.Pin = pin;
}
public static string GetUserInfoPIN()
{
return UserInfo.Pin;
}
...
}

using:

set
switch (dropdlFor.SelectedIndex)
{
case 0: GData.SetQDataFOR("all");break;
case 1: GData.SetQDataFOR("week"); break;
...
}

get
if (e.CommandName == "Update")
{
...
done.Parameters["Done"].Value = GData.GetQDataCOND();
done.Parameters["id_zh"].Value = GData.GetQDataIDZ();
conn.Open();
done.ExecuteNonQuery();
conn.Close();
}

Advertisements
  1. baurdotnet
    Thursday, 15 May, 2008 at 9:32 am

    no perfect way of course, any suggestions?!

  2. Thursday, 15 May, 2008 at 7:04 pm

    Looks like very interesting 😉

  3. baurdotnet
    Friday, 16 May, 2008 at 12:02 pm

    Note: static variables are overwritten whn another user login to system, this data available for all sessions, all changes in variable affects for all sessions at once

  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: