473,609 Members | 1,871 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

need help on scope of a function for intellisence

Hi,

I am writing a webpage in C#. Visual Studio .NET.

the following code does not provide me with intellisence on the context,
session, and page.cache.

When I put the large if...then statment from the GetJSHyperlinks String()
function
into the private void on page load event the intellisence works fine.

I pretty sure I'm not declaring the function properly and my scope is wrong.
the function is : public static string GetJSHyperlinks String()

I also get object reference is required for nonstatic field and a property
where a class was expected errors at compile on the context, session, and
page.cache statements.

Please advise.

code is:

public class leftnav : System.Web.UI.P age
{
public const string CACHE_NAV_DATA = "NavData";
public const string SESSION_NAV_DAT A = "UserSessionNav Data";

protected System.Web.UI.H tmlControls.Htm lForm Form1;

private void Page_Load(objec t sender, System.EventArg s e)

{
RegisterLinkBut tonScript();
}

public static string GetJSHyperlinks String()
{
//this function will determine the hyperlinks available to the logged
//in user by reading the database. Default hyperlinks are constructed
//for those who are not logged in.

object objsession;
string JSHyperlinksStr ing = string.Empty;

//check to see if the hyperlinks already exist.
//this javascript code is parsed by the worker thread into an
//unmanaged client side code whenever it is retrieved by the
//page.cache.get method

if(Context.User .Identity.IsAut henticated)
{
objsession = Session[SESSION_NAV_DAT A];
}
else
{
objsession = Page.Cache[CACHE_NAV_DATA];
}

Nov 17 '05 #1
7 1332
hi,

put three /// in the line above the function declaration, the IDE will
expand it with the structure needed.

cheers,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation
"Chris" <Ch***@discussi ons.microsoft.c om> wrote in message
news:91******** *************** ***********@mic rosoft.com...
Hi,

I am writing a webpage in C#. Visual Studio .NET.

the following code does not provide me with intellisence on the context,
session, and page.cache.

When I put the large if...then statment from the GetJSHyperlinks String()
function
into the private void on page load event the intellisence works fine.

I pretty sure I'm not declaring the function properly and my scope is
wrong.
the function is : public static string GetJSHyperlinks String()

I also get object reference is required for nonstatic field and a property
where a class was expected errors at compile on the context, session, and
page.cache statements.

Please advise.

code is:

public class leftnav : System.Web.UI.P age
{
public const string CACHE_NAV_DATA = "NavData";
public const string SESSION_NAV_DAT A = "UserSessionNav Data";

protected System.Web.UI.H tmlControls.Htm lForm Form1;

private void Page_Load(objec t sender, System.EventArg s e)

{
RegisterLinkBut tonScript();
}

public static string GetJSHyperlinks String()
{
//this function will determine the hyperlinks available to the logged
//in user by reading the database. Default hyperlinks are constructed
//for those who are not logged in.

object objsession;
string JSHyperlinksStr ing = string.Empty;

//check to see if the hyperlinks already exist.
//this javascript code is parsed by the worker thread into an
//unmanaged client side code whenever it is retrieved by the
//page.cache.get method

if(Context.User .Identity.IsAut henticated)
{
objsession = Session[SESSION_NAV_DAT A];
}
else
{
objsession = Page.Cache[CACHE_NAV_DATA];
}


Nov 17 '05 #2

public const string CACHE_NAV_DATA = "NavData";
public const string SESSION_NAV_DAT A = "UserSessionNav Data";

please replace :
public string CACHE_NAV_DATA = "NavData";
public string SESSION_NAV_DAT A = "UserSessionNav Data";

"Chris" wrote:
Hi,

I am writing a webpage in C#. Visual Studio .NET.

the following code does not provide me with intellisence on the context,
session, and page.cache.

When I put the large if...then statment from the GetJSHyperlinks String()
function
into the private void on page load event the intellisence works fine.

I pretty sure I'm not declaring the function properly and my scope is wrong.
the function is : public static string GetJSHyperlinks String()

I also get object reference is required for nonstatic field and a property
where a class was expected errors at compile on the context, session, and
page.cache statements.

Please advise.

code is:

public class leftnav : System.Web.UI.P age
{
public const string CACHE_NAV_DATA = "NavData";
public const string SESSION_NAV_DAT A = "UserSessionNav Data";

protected System.Web.UI.H tmlControls.Htm lForm Form1;

private void Page_Load(objec t sender, System.EventArg s e)

{
RegisterLinkBut tonScript();
}

public static string GetJSHyperlinks String()
{
//this function will determine the hyperlinks available to the logged
//in user by reading the database. Default hyperlinks are constructed
//for those who are not logged in.

object objsession;
string JSHyperlinksStr ing = string.Empty;

//check to see if the hyperlinks already exist.
//this javascript code is parsed by the worker thread into an
//unmanaged client side code whenever it is retrieved by the
//page.cache.get method

if(Context.User .Identity.IsAut henticated)
{
objsession = Session[SESSION_NAV_DAT A];
}
else
{
objsession = Page.Cache[CACHE_NAV_DATA];
}

Nov 17 '05 #3
this does'nt seem to help, it causes more errors to occur in the build.
I also don't think this is related to my problem.

thanks

"Keko" wrote:

public const string CACHE_NAV_DATA = "NavData";
public const string SESSION_NAV_DAT A = "UserSessionNav Data";

please replace :
public string CACHE_NAV_DATA = "NavData";
public string SESSION_NAV_DAT A = "UserSessionNav Data";

"Chris" wrote:
Hi,

I am writing a webpage in C#. Visual Studio .NET.

the following code does not provide me with intellisence on the context,
session, and page.cache.

When I put the large if...then statment from the GetJSHyperlinks String()
function
into the private void on page load event the intellisence works fine.

I pretty sure I'm not declaring the function properly and my scope is wrong.
the function is : public static string GetJSHyperlinks String()

I also get object reference is required for nonstatic field and a property
where a class was expected errors at compile on the context, session, and
page.cache statements.

Please advise.

code is:

public class leftnav : System.Web.UI.P age
{
public const string CACHE_NAV_DATA = "NavData";
public const string SESSION_NAV_DAT A = "UserSessionNav Data";

protected System.Web.UI.H tmlControls.Htm lForm Form1;

private void Page_Load(objec t sender, System.EventArg s e)

{
RegisterLinkBut tonScript();
}

public static string GetJSHyperlinks String()
{
//this function will determine the hyperlinks available to the logged
//in user by reading the database. Default hyperlinks are constructed
//for those who are not logged in.

object objsession;
string JSHyperlinksStr ing = string.Empty;

//check to see if the hyperlinks already exist.
//this javascript code is parsed by the worker thread into an
//unmanaged client side code whenever it is retrieved by the
//page.cache.get method

if(Context.User .Identity.IsAut henticated)
{
objsession = Session[SESSION_NAV_DAT A];
}
else
{
objsession = Page.Cache[CACHE_NAV_DATA];
}

Nov 17 '05 #4
I added the /// to just before the function starts, it created my summary and
tags.
However I still have same problem.

How does adding comments to the function change the scope and availablity
of the assemblies to the function?
curious.

"Ignacio Machin ( .NET/ C# MVP )" wrote:
hi,

put three /// in the line above the function declaration, the IDE will
expand it with the structure needed.

cheers,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation
"Chris" <Ch***@discussi ons.microsoft.c om> wrote in message
news:91******** *************** ***********@mic rosoft.com...
Hi,

I am writing a webpage in C#. Visual Studio .NET.

the following code does not provide me with intellisence on the context,
session, and page.cache.

When I put the large if...then statment from the GetJSHyperlinks String()
function
into the private void on page load event the intellisence works fine.

I pretty sure I'm not declaring the function properly and my scope is
wrong.
the function is : public static string GetJSHyperlinks String()

I also get object reference is required for nonstatic field and a property
where a class was expected errors at compile on the context, session, and
page.cache statements.

Please advise.

code is:

public class leftnav : System.Web.UI.P age
{
public const string CACHE_NAV_DATA = "NavData";
public const string SESSION_NAV_DAT A = "UserSessionNav Data";

protected System.Web.UI.H tmlControls.Htm lForm Form1;

private void Page_Load(objec t sender, System.EventArg s e)

{
RegisterLinkBut tonScript();
}

public static string GetJSHyperlinks String()
{
//this function will determine the hyperlinks available to the logged
//in user by reading the database. Default hyperlinks are constructed
//for those who are not logged in.

object objsession;
string JSHyperlinksStr ing = string.Empty;

//check to see if the hyperlinks already exist.
//this javascript code is parsed by the worker thread into an
//unmanaged client side code whenever it is retrieved by the
//page.cache.get method

if(Context.User .Identity.IsAut henticated)
{
objsession = Session[SESSION_NAV_DAT A];
}
else
{
objsession = Page.Cache[CACHE_NAV_DATA];
}


Nov 17 '05 #5
Hi Chris,

why the GetJSHyperlinks String() is static?

I suppose you're trying to access instance members inside a static member.
That's not possible.

Christof

"Chris" <Ch***@discussi ons.microsoft.c om> schrieb im Newsbeitrag
news:91******** *************** ***********@mic rosoft.com...
Hi,

I am writing a webpage in C#. Visual Studio .NET.

the following code does not provide me with intellisence on the context,
session, and page.cache.

When I put the large if...then statment from the GetJSHyperlinks String()
function
into the private void on page load event the intellisence works fine.

I pretty sure I'm not declaring the function properly and my scope is
wrong.
the function is : public static string GetJSHyperlinks String()

I also get object reference is required for nonstatic field and a property
where a class was expected errors at compile on the context, session, and
page.cache statements.

Please advise.

code is:

public class leftnav : System.Web.UI.P age
{
public const string CACHE_NAV_DATA = "NavData";
public const string SESSION_NAV_DAT A = "UserSessionNav Data";

protected System.Web.UI.H tmlControls.Htm lForm Form1;

private void Page_Load(objec t sender, System.EventArg s e)

{
RegisterLinkBut tonScript();
}

public static string GetJSHyperlinks String()
{
//this function will determine the hyperlinks available to the logged
//in user by reading the database. Default hyperlinks are constructed
//for those who are not logged in.

object objsession;
string JSHyperlinksStr ing = string.Empty;

//check to see if the hyperlinks already exist.
//this javascript code is parsed by the worker thread into an
//unmanaged client side code whenever it is retrieved by the
//page.cache.get method

if(Context.User .Identity.IsAut henticated)
{
objsession = Session[SESSION_NAV_DAT A];
}
else
{
objsession = Page.Cache[CACHE_NAV_DATA];
}


Nov 17 '05 #6
Hi Christof,

I just finished reading about that in the documentation.

i put static because I want my function to return a value without creating
an instance of itself, basically a function like found in an inception
filter pattern to
perform a generic process.

I removed the static and it works fine.

thanks
"Christof Nordiek" wrote:
Hi Chris,

why the GetJSHyperlinks String() is static?

I suppose you're trying to access instance members inside a static member.
That's not possible.

Christof

"Chris" <Ch***@discussi ons.microsoft.c om> schrieb im Newsbeitrag
news:91******** *************** ***********@mic rosoft.com...
Hi,

I am writing a webpage in C#. Visual Studio .NET.

the following code does not provide me with intellisence on the context,
session, and page.cache.

When I put the large if...then statment from the GetJSHyperlinks String()
function
into the private void on page load event the intellisence works fine.

I pretty sure I'm not declaring the function properly and my scope is
wrong.
the function is : public static string GetJSHyperlinks String()

I also get object reference is required for nonstatic field and a property
where a class was expected errors at compile on the context, session, and
page.cache statements.

Please advise.

code is:

public class leftnav : System.Web.UI.P age
{
public const string CACHE_NAV_DATA = "NavData";
public const string SESSION_NAV_DAT A = "UserSessionNav Data";

protected System.Web.UI.H tmlControls.Htm lForm Form1;

private void Page_Load(objec t sender, System.EventArg s e)

{
RegisterLinkBut tonScript();
}

public static string GetJSHyperlinks String()
{
//this function will determine the hyperlinks available to the logged
//in user by reading the database. Default hyperlinks are constructed
//for those who are not logged in.

object objsession;
string JSHyperlinksStr ing = string.Empty;

//check to see if the hyperlinks already exist.
//this javascript code is parsed by the worker thread into an
//unmanaged client side code whenever it is retrieved by the
//page.cache.get method

if(Context.User .Identity.IsAut henticated)
{
objsession = Session[SESSION_NAV_DAT A];
}
else
{
objsession = Page.Cache[CACHE_NAV_DATA];
}


Nov 17 '05 #7
Keko <Ke**@discussio ns.microsoft.co m> wrote:
public const string CACHE_NAV_DATA = "NavData";
public const string SESSION_NAV_DAT A = "UserSessionNav Data";

please replace :
public string CACHE_NAV_DATA = "NavData";
public string SESSION_NAV_DAT A = "UserSessionNav Data";


Why? They're constant strings, and they don't need to be writable as
far as I can see...

--
Jon Skeet - <sk***@pobox.co m>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 17 '05 #8

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

Similar topics

7
2304
by: Ben Thomas | last post by:
Hi all, I'm having some trouble understanding the behavior of std::ostringstream. (I'm using Visual Studio .Net & STL port 4.5.3). I'll appreciate if someone can give me a little explanation of this behavior and how it is possible... Here's my code ////////////////////////// #include <stdio.h>
15
3668
by: drdoubt | last post by:
using namespace std In my C++ program, even after applying , I need to use the std namespace with the scope resolution operator, like, std::cout, std::vector. This I found a little bit cumbersome to always include std. I somewhere found a trick to overcome this problem. By using using std::cout;
1
6080
by: bin_P19 P | last post by:
the code i have got is as follows and now im stuck <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <title>Shopping Cart</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <link rel="StyleSheet" href="css/style.css" type="text/css">
5
2082
by: pembed2003 | last post by:
Hi all, I am reading the book "C How to Program" and in the chapter where it discuss scope rule, it says there are four scopes for a variable: function scope file scope block scope function-prototype scope I think(might be wrong):
8
3367
by: TTroy | last post by:
I have a few questions about "scope" and "visibility," which seem like two different things. To me "visibility" of the name of a function or object is the actual code that can use it in an actual program. To me "scope" of the name of a function or object are the general rules for the areas of a program that can through a declaration, have "visibility."
2
9169
by: Jon Davis | last post by:
The garbage handler in the .NET framework is handy. When objects fall out of scope, they are automatically destroyed, and the programmer doesn't have to worry about deallocating the memory space for those objects. In fact, all the programmer has to worry about is the total sum of objects loaded into RAM at any known point. Memory leaks are not a problem. .... So one would like to think. The reality is that delegates and event...
1
1561
by: Rob Panosh | last post by:
Hello, Does anybody know of a control that I can put on a form that would allow intellisence at runtime? Sorta like the "Command Window" when debugging your source code. I would like to use this control so users can type in source code, referencing my assemblies, at runtime with intellisence then I could compile and run. Thanks, Rob Panosh
2
1276
by: Ariansen Jon Haakon | last post by:
Hi, I see that all objects in the framework sdk has description in intellisence. It would be nice to create descriptions on my own objects that I can see in intellisence. Is that possible?? In advance thanks a lot for your reply. Kind regards, Jon Haakon
1
25654
pbmods
by: pbmods | last post by:
VARIABLE SCOPE IN JAVASCRIPT LEVEL: BEGINNER/INTERMEDIATE (INTERMEDIATE STUFF IN ) PREREQS: VARIABLES First off, what the heck is 'scope' (the kind that doesn't help kill the germs that cause bad breath)? Scope describes the context in which a variable can be used. For example, if a variable's scope is a certain function, then that variable can only be used in that function. If you were to try to access that variable anywhere else in...
0
8130
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8076
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8573
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8222
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8406
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6057
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5510
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4021
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2531
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.