Code behind project and I need to declare a global veriable where do I do it at

  • Thread starter Thread starter Bryan G
  • Start date Start date
B

Bryan G

Code behind project and I need to declare a global veriable where do I do
this since there is no .h file
 
Ok I tried doing the latter. Here is my code but I get an error saying that

The name 'CfgKeyFirstDayOfWeek' does not exist in the class or namespace
'DashBoard.DashBoardForm'
am I putting it in the wrong place?
namespace DashBoard

{




public class Global : System.Web.HttpApplication

{

public const string CfgKeyFirstDayOfWeek = "FirstDayOfWeek";



public Global()

{

InitializeComponent();

}

}

Tap said:
Bryan,

You can use web.config file to declare additional variables as follows.

<appSettings><add key="ConnectString" value="server=xyz;User
Id=tap;Password='nopass';" /> said:
You can read them using

ConfigurationSettings.AppSettings["ConnectString"]

Make sure to include the "System.Configuration" namespace.

OR

You can also define as follows in global.aspx

public const string CfgKeyFirstDayOfWeek = "FirstDayOfWeek";

and use across your application.

Hope this helps.

Thanks,

Tap
 
Bryan

If you define it in the Global, you can fetch it as follows

ConfigurationSettings.AppSettings[Web.Global.CfgKeyConnString

Thanks,

Ta
 
Back
Top