473,327 Members | 1,976 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,327 software developers and data experts.

calling class method

I am trying to create instance of class and and call a method of this class
that creates a global variable which is available in anywhere in the page..

Here is what i am doing.. but i am getting build error message as shown:

C:\Inetpub\aspnet\intranet\bs\request.aspx.cs(45):
'intranet.departments.building_services.request.NT Security' denotes a 'field'
where a 'class' was expected

The line in question is:
protected string LogonUser = NTSecurity.getLogonUser();

Basically i want to access this variable from any mothods inside the page
without keeping calling this line of code in every methods.

public class request : System.Web.UI.Page
{
protected security NTSecurity = new security();
protected string LogonUser = NTSecurity.getLogonUser();
private void Page_Load(object sender, System.EventArgs e)
{

}

any suggestion how? many thanks in advance

Nov 18 '05 #1
5 1557
hi

if you want to create an instace use this constructor for your class.
public static readonly Application Instance = new Application();
and access this like Application.Instance.Method.

Cheers
"huzz" wrote:
I am trying to create instance of class and and call a method of this class
that creates a global variable which is available in anywhere in the page..

Here is what i am doing.. but i am getting build error message as shown:

C:\Inetpub\aspnet\intranet\bs\request.aspx.cs(45):
'intranet.departments.building_services.request.NT Security' denotes a 'field'
where a 'class' was expected

The line in question is:
protected string LogonUser = NTSecurity.getLogonUser();

Basically i want to access this variable from any mothods inside the page
without keeping calling this line of code in every methods.

public class request : System.Web.UI.Page
{
protected security NTSecurity = new security();
protected string LogonUser = NTSecurity.getLogonUser();
private void Page_Load(object sender, System.EventArgs e)
{

}

any suggestion how? many thanks in advance

Nov 18 '05 #2
bit confused :( can't i not do the way i am trying to do?

"Psycho" wrote:
hi

if you want to create an instace use this constructor for your class.
public static readonly Application Instance = new Application();
and access this like Application.Instance.Method.

Cheers
"huzz" wrote:
I am trying to create instance of class and and call a method of this class
that creates a global variable which is available in anywhere in the page..

Here is what i am doing.. but i am getting build error message as shown:

C:\Inetpub\aspnet\intranet\bs\request.aspx.cs(45):
'intranet.departments.building_services.request.NT Security' denotes a 'field'
where a 'class' was expected

The line in question is:
protected string LogonUser = NTSecurity.getLogonUser();

Basically i want to access this variable from any mothods inside the page
without keeping calling this line of code in every methods.

public class request : System.Web.UI.Page
{
protected security NTSecurity = new security();
protected string LogonUser = NTSecurity.getLogonUser();
private void Page_Load(object sender, System.EventArgs e)
{

}

any suggestion how? many thanks in advance

Nov 18 '05 #3
You say you want a class which is available globally .
I think you want a custom page but i didn't understand from first time your
question. So Create a custom page and there you can put session variables and
also global variable if you need this in every page. And then derive all of
your pages from that page.

"huzz" wrote:
bit confused :( can't i not do the way i am trying to do?

"Psycho" wrote:
hi

if you want to create an instace use this constructor for your class.
public static readonly Application Instance = new Application();
and access this like Application.Instance.Method.

Cheers
"huzz" wrote:
I am trying to create instance of class and and call a method of this class
that creates a global variable which is available in anywhere in the page..

Here is what i am doing.. but i am getting build error message as shown:

C:\Inetpub\aspnet\intranet\bs\request.aspx.cs(45):
'intranet.departments.building_services.request.NT Security' denotes a 'field'
where a 'class' was expected

The line in question is:
protected string LogonUser = NTSecurity.getLogonUser();

Basically i want to access this variable from any mothods inside the page
without keeping calling this line of code in every methods.

public class request : System.Web.UI.Page
{
protected security NTSecurity = new security();
protected string LogonUser = NTSecurity.getLogonUser();
private void Page_Load(object sender, System.EventArgs e)
{

}

any suggestion how? many thanks in advance

Nov 18 '05 #4
If you declare your variable in the page class you will lose the value every
time the page is called so it will not be a global variable.
You should instead use a Session object if you want the variable available
for each session or an Application object if you want it available for the
lifetime of the Application all sessions that is.

Enrique.

"huzz" <hu**@discussions.microsoft.com> wrote in message
news:36**********************************@microsof t.com...
I am trying to create instance of class and and call a method of this class
that creates a global variable which is available in anywhere in the
page..

Here is what i am doing.. but i am getting build error message as shown:

C:\Inetpub\aspnet\intranet\bs\request.aspx.cs(45):
'intranet.departments.building_services.request.NT Security' denotes a
'field'
where a 'class' was expected

The line in question is:
protected string LogonUser = NTSecurity.getLogonUser();

Basically i want to access this variable from any mothods inside the page
without keeping calling this line of code in every methods.

public class request : System.Web.UI.Page
{
protected security NTSecurity = new security();
protected string LogonUser = NTSecurity.getLogonUser();
private void Page_Load(object sender, System.EventArgs e)
{

}

any suggestion how? many thanks in advance

Nov 18 '05 #5
i want the variable to be available in that page only, i don't want to make
it application variable or session variable..

Many thanks

"Enrique Santa Cruz" wrote:
If you declare your variable in the page class you will lose the value every
time the page is called so it will not be a global variable.
You should instead use a Session object if you want the variable available
for each session or an Application object if you want it available for the
lifetime of the Application all sessions that is.

Enrique.

"huzz" <hu**@discussions.microsoft.com> wrote in message
news:36**********************************@microsof t.com...
I am trying to create instance of class and and call a method of this class
that creates a global variable which is available in anywhere in the
page..

Here is what i am doing.. but i am getting build error message as shown:

C:\Inetpub\aspnet\intranet\bs\request.aspx.cs(45):
'intranet.departments.building_services.request.NT Security' denotes a
'field'
where a 'class' was expected

The line in question is:
protected string LogonUser = NTSecurity.getLogonUser();

Basically i want to access this variable from any mothods inside the page
without keeping calling this line of code in every methods.

public class request : System.Web.UI.Page
{
protected security NTSecurity = new security();
protected string LogonUser = NTSecurity.getLogonUser();
private void Page_Load(object sender, System.EventArgs e)
{

}

any suggestion how? many thanks in advance


Nov 18 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Chris | last post by:
Hi I have a scenario where I've created another AppDomain to dynamically load a DLL(s) into. In this newly loaded DLL I want to call a static method on a class. The problem arise is that I have...
7
by: Klaus Friese | last post by:
Hi, i'm currently working on a plugin for Adobe InDesign and i have some problems with that. I'm not really a c++ guru, maybe somebody here has an idea how to solve this. The plugin is...
5
by: Dave Veeneman | last post by:
I'm using inheritance more than I used to, and I find myself calling a lot of base class methods. I generally call a base method from a dreived class like this: this.MyMethod(); I'm finding...
7
by: JJ | last post by:
Hi, I call a class in my windows service app and in that class I access a method that returns an OleDbReader. Now It does have records in the reader when I step through the method but when I...
5
by: Nick Flandry | last post by:
I'm running into an Invalid Cast Exception on an ASP.NET application that runs fine in my development environment (Win2K server running IIS 5) and a test environment (also Win2K server running IIS...
12
by: Ron | last post by:
Greetings, I am trying to understand the rational for Raising Events instead of just calling a sub. Could someone explain the difference between the following 2 scenarios? Why would I want to...
0
by: han zhiyang | last post by:
I've just studied the "how to" web service and the async pattern in donnet.I make a test with these knowledges,but I got a strange result. Here is my test. 1.Write a simple "Add" service named...
6
by: Anthony Smith | last post by:
I can call a class using "->", but it complains about the :: I see on the net where :: is used. Is there a good explanation on when to use one over the other or the differences? $help = new...
10
by: Finger.Octopus | last post by:
Hello, I have been trying to call the super constructor from my derived class but its not working as expected. See the code: class HTMLMain: def __init__(self): self.text = "<HTML><BODY>";...
7
by: =?Utf-8?B?UVNJRGV2ZWxvcGVy?= | last post by:
I have a C# logging assembly with a static constructor and methods that is called from another C# Assembly that is used as a COM interface for a VB6 Application. Ideally I need to build a file...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.