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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top