473,387 Members | 1,899 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,387 software developers and data experts.

Class Visibility Question

BG
Hey All,

I have a simple understanding of session variables. Can the same thing be
done with a class in ASP.net?

Such as default.aspx contains a new instance of MYClass. So I load
MyClass.MyName = "Fred". Now ,umpteen response.redirects later, umpteen
pages later deep within the web site, I want to display MyClass.MyName and
it will still contain "Fred".

Possible?

Thanks,

BG

Nov 19 '05 #1
2 863
One ot the ways to achieve this is to store the object in the Session
and later retrieve it:

Session["MyClass"] = MyClass

The object is stored in the Session object until it is explicitly
removed, the session times out or is emptied in some other way. You
retirieve it when you like with guarantee that it is not changed unless
you have changed it yourself:
MYClass MyClass = (MYClass)Session["MyClass"];

Nov 19 '05 #2
You can map a property to a session

class X
{
public strinf NAme
{
get
{
return (string)Session["Name"];
}
set
{
Session["Name"] = value;
}
}
}

--
Daniel Fisher(lennybacon)
MCP ASP.NET C#
Blog: http://www.lennybacon.com/
"BG" <bg*****@yahoo.com> wrote in message
news:41***********************@news.skynet.be...
Hey All,

I have a simple understanding of session variables. Can the same thing be
done with a class in ASP.net?

Such as default.aspx contains a new instance of MYClass. So I load
MyClass.MyName = "Fred". Now ,umpteen response.redirects later, umpteen
pages later deep within the web site, I want to display MyClass.MyName and
it will still contain "Fred".

Possible?

Thanks,

BG

Nov 19 '05 #3

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

Similar topics

9
by: lkrubner | last post by:
How do I get all the div's on a page? I realize in IE I can use document.all. For the other browsers, I need to get an array of all the divs on the page. getElementByTagName()?????
12
by: Rennie deGraaf | last post by:
I have a system that looks like this: class AbstractBase { /* ... */ }; template <class T> class Impl : public AbstractBase { /* ... */ }; // ... Impl<int> i; Impl<float> f;...
4
by: Colin Desmond | last post by:
Is it possible to write an attribute that changes the visibility of a class (public/private) etc based on some pre-compiler define symbol? We're writing some classes which will be called by an...
52
by: Ben Voigt [C++ MVP] | last post by:
I get C:\Programming\LTM\devtools\UselessJunkForDissassembly\Class1.cs(360,27): error CS0535: 'UselessJunkForDissassembly.InvocableInternals' does not implement interface member...
10
by: Janis Papanagnou | last post by:
The task seems simple but I am not sure whether this is possible or even the right way to look at it... I have <td class="X"elements where "X" is a placeholder for class names "A", "B", etc. ...
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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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
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,...

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.