473,386 Members | 1,799 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,386 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 1560
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: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.