Hi all,
I have a class file called Properties.vb in which I define a publi
property as follows
-----------------------------------------------------------
Public Class Properties
Private CalSelectedDate As Date = Now()
Public Property CalSelDate() As Date
Get
Return CalSelectedDate
End Get
Set(ByVal Value As Date)
CalSelectedDate = Value
End Set
End Property
End Class
-----------------------------------------------------------
Now I have Page1.aspx where I create an object of Properties class an
set the property value.
I also have Page2.aspx where I create another object of Properies clas
and try to access the property value - But I dont get it.
Im guessing this is because each object I create has its own memor
space...
So how would I be able to accomplish this ? How do I get values fro
another class ?
TIA,
A
ajaymehr
-----------------------------------------------------------------------
Posted via http://www.mcse.m
-----------------------------------------------------------------------
View this thread: http://www.mcse.ms/message409039.htm 5 1148
Every instance of a class (object) contains its own copy of each member
variable. If you are navigating to Page 2, Page 1 is already gone, and you
can't get to it any more. If you try to just create a new instance, you get
exactly that: a new instance. If you want to pass information back and
forth, you should try using a Session variable, using Server. Transfer, or
other such means to preserve the state that you need to access from the next
page.
--
Chris Jackson
Software Engineer
Microsoft MVP - Windows Client
Windows XP Associate Expert
--
More people read the newsgroups than read my email.
Reply to the newsgroup for a faster response.
(Control-G using Outlook Express)
--
"ajaymehra" <aj************ **@mail.mcse.ms > wrote in message
news:aj******** ******@mail.mcs e.ms... Hi all, I have a class file called Properties.vb in which I define a public property as follows ----------------------------------------------------------- Public Class Properties Private CalSelectedDate As Date = Now()
Public Property CalSelDate() As Date Get Return CalSelectedDate End Get Set(ByVal Value As Date) CalSelectedDate = Value End Set End Property
End Class -----------------------------------------------------------
Now I have Page1.aspx where I create an object of Properties class and set the property value. I also have Page2.aspx where I create another object of Properies class and try to access the property value - But I dont get it.
Im guessing this is because each object I create has its own memory space... So how would I be able to accomplish this ? How do I get values from another class ?
TIA, AJ
ajaymehra ------------------------------------------------------------------------ Posted via http://www.mcse.ms ------------------------------------------------------------------------ View this thread: http://www.mcse.ms/message409039.html
Ajaymehra,
It sounds like you are expecting that IIS will hold an instance of that
object in memory for as long as you need it. In fact, that's not what
happens. When you instantiate that object, you can use that object until
the page class is destroyed. That happens when the page is sent to the
Response stream. If you want to access the instance you create on Webform1
in another page, you have to explicitly persist that instance using Session
state, Viewstate, or some other method.
Jim Cheshire, MCSE, MCSD [MSFT]
ASP.NET
Developer Support ja******@online .microsoft.com
This post is provided as-is with no warranties and confers no rights.
-------------------- NNTP-Posting-Date: Thu, 19 Feb 2004 13:28:34 -0600 From: ajaymehra <aj************ **@mail.mcse.ms > Newsgroups: microsoft.publi c.dotnet.framew ork.aspnet Subject: question about classes Date: Thu, 19 Feb 2004 13:41:01 -0600 Message-ID: <aj************ **@mail.mcse.ms > Organization : MCSE.MS forum User-Agent: MCSE.MS news gateway X-Newsreader: MCSE.MS news gateway X-Originating-IP: 167.89.2.5 Lines: 26 X-Trace:
sv3-RuVh3tOqYkjiolp ygEWMy10+aew0ze nSGXC4c6YnqScfC PTLVDR3N2Ex3Y4c QPgjA9J93c1g
0fvDTCb!XsvOj0y FkFsyRFP9bXi6PT 3tJMTUZQkYTomnQ AW46Bu25B6xIWk=X-Complaints-To: ab***@giganews. com X-DMCA-Notifications: http://www.giganews.com/info/dmca.html X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your
complaint properlyX-Postfilter: 1.1 Path:
cpmsftngxa07.ph x.gbl!cpmsftngx a06.phx.gbl!cpm sftngxa09.phx.g bl!TK2MSFTNGP08 .
phx.gbl!newsfee d00.sul.t-online.de!newsf eed01.sul.t-online.de!t-online.de!ne
wspeer1-gui.server.ntli .net!ntli.net!n ewspeer1-win.server.ntli .net!border1.n
ntp.ash.giganew s.com!border2.n ntp.sjc.giganew s.com!border1.n ntp.sjc.giganew s
.com!nntp.gigan ews.com!local1. nntp.sjc.gigane ws.com!news.gig anews.com.POSTE D
!not-for-mailXref: cpmsftngxa07.ph x.gbl microsoft.publi c.dotnet.framew ork.aspnet:2115 29 X-Tomcat-NG: microsoft.publi c.dotnet.framew ork.aspnet
Hi all,I have a class file called Properties.vb in which I define a public
property as follows----------------------------------------------------------- Public Class Properties Private CalSelectedDate As Date = Now()
Public Property CalSelDate() As Date Get Return CalSelectedDate End Get Set(ByVal Value As Date) CalSelectedDat e = Value End Set End Property
End Class -----------------------------------------------------------
Now I have Page1.aspx where I create an object of Properties class and
set the property value.I also have Page2.aspx where I create another object of Properies class
and try to access the property value - But I dont get it. Im guessing this is because each object I create has its own memory
space...So how would I be able to accomplish this ? How do I get values from
another class ? TIA, AJ
ajaymehra
------------------------------------------------------------------------
Posted via http://www.mcse.ms
------------------------------------------------------------------------
View this thread: http://www.mcse.ms/message409039.html
> Now I have Page1.aspx where I create an object of Properties class and set the property value. I also have Page2.aspx where I create another object of Properies class and try to access the property value - But I dont get it.
Im guessing this is because each object I create has its own memory space... So how would I be able to accomplish this ? How do I get values from another class ?
Get them from the class instance that you set the property in. A class
definition is just that: It defines the structure of a class, but is not an
instance of the class, just a blueprint if you will. Using the New Operator
or any other method that returns an instance of that class creates an
instance of the class. And you can create as many instances of a class as
you like. If the class definition is a blueprint, the class instance is the
house. You can build many houses from a single blueprint.
Now, I believe that the real issue you're dealing with is, how do you access
a class that was created in another Page? The answer is not all that simple,
as there are many ways, depending upon how that second Page is arrived at.
For example, if you do a Server.Transfer , you can literally transfer the
class instance to the page being transferred to. On the other hand, more
often than not you're likely to want to store the class instance in a cache
of one sort or another, such as SessionState or Application Cache. Where you
store it depends on how much accessibility it needs. If you store it in
Session, it is available to all Pages seen by a single user. If you store in
Application Cache, it is available to all pages seen by all users.
--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Big things are made up
of lots of little things.
--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Big things are made up
of lots of little things.
"ajaymehra" <aj************ **@mail.mcse.ms > wrote in message
news:aj******** ******@mail.mcs e.ms... Hi all, I have a class file called Properties.vb in which I define a public property as follows ----------------------------------------------------------- Public Class Properties Private CalSelectedDate As Date = Now()
Public Property CalSelDate() As Date Get Return CalSelectedDate End Get Set(ByVal Value As Date) CalSelectedDate = Value End Set End Property
End Class -----------------------------------------------------------
Now I have Page1.aspx where I create an object of Properties class and set the property value. I also have Page2.aspx where I create another object of Properies class and try to access the property value - But I dont get it.
Im guessing this is because each object I create has its own memory space... So how would I be able to accomplish this ? How do I get values from another class ?
TIA, AJ
ajaymehra ------------------------------------------------------------------------ Posted via http://www.mcse.ms ------------------------------------------------------------------------ View this thread: http://www.mcse.ms/message409039.html
Thanks all of you for clearing up my concepts.
Kevin - That blueprint...hou se example was excellent.
Thanks again
Kevin Spencer wrote: *> Now I have Page1.aspx where I create an object of Properties clas and set the property value. I also have Page2.aspx where I create another object of Properie class and try to access the property value - But I dont get it.
Im guessing this is because each object I create has its ow memory space... So how would I be able to accomplish this ? How do I get value from another class ?
Get them from the class instance that you set the property in. class definition is just that: It defines the structure of a class, but i not an instance of the class, just a blueprint if you will. Using the Ne Operator or any other method that returns an instance of that class create an instance of the class. And you can create as many instances of class as you like. If the class definition is a blueprint, the class instanc is the house. You can build many houses from a single blueprint.
Now, I believe that the real issue you're dealing with is, how do yo access a class that was created in another Page? The answer is not all tha simple, as there are many ways, depending upon how that second Page i arrived at. For example, if you do a Server.Transfer , you can literally transfe the class instance to the page being transferred to. On the other hand more often than not you're likely to want to store the class instance in cache of one sort or another, such as SessionState or Application Cache Where you store it depends on how much accessibility it needs. If you store i in Session, it is available to all Pages seen by a single user. If yo store in Application Cache, it is available to all pages seen by all users.
-- HTH, Kevin Spencer ..Net Developer Microsoft MVP Big things are made up of lots of little things.
-- HTH, Kevin Spencer ..Net Developer Microsoft MVP Big things are made up of lots of little things.
"ajaymehra" <aj************ **@mail.mcse.ms > wrote in message news:aj******** ******@mail.mcs e.ms... Hi all, I have a class file called Properties.vb in which I define
public property as follows ----------------------------------------------------------- Public Class Properties Private CalSelectedDate As Date = Now()
Public Property CalSelDate() As Date Get Return CalSelectedDate End Get Set(ByVal Value As Date) CalSelectedDate = Value End Set End Property
End Class -----------------------------------------------------------
Now I have Page1.aspx where I create an object of Properties clas and set the property value. I also have Page2.aspx where I create another object of Properie class and try to access the property value - But I dont get it.
Im guessing this is because each object I create has its ow memory space... So how would I be able to accomplish this ? How do I get value from another class ?
TIA, AJ
ajaymehra
------------------------------------------------------------------------ Posted via http://www.mcse.ms
------------------------------------------------------------------------ View this thread: http://www.mcse.ms/message409039.html
ajaymehr
-----------------------------------------------------------------------
Posted via http://www.mcse.m
-----------------------------------------------------------------------
View this thread: http://www.mcse.ms/message409039.htm
He could also use a Shared instance.
Jim Cheshire, MCSE, MCSD [MSFT]
ASP.NET
Developer Support ja******@online .microsoft.com
This post is provided as-is with no warranties and confers no rights.
-------------------- From: "Chris Jackson" <chrisjATmvpsDO TorgNOSPAM> References: <aj************ **@mail.mcse.ms > Subject: Re: question about classes Date: Thu, 19 Feb 2004 15:33:32 -0500 Lines: 63 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2900.2055 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2055 X-RFC2646: Format=Flowed; Original Message-ID: <O9************ **@TK2MSFTNGP09 .phx.gbl> Newsgroups: microsoft.publi c.dotnet.framew ork.aspnet NNTP-Posting-Host: 208.252.52.2 Path:
cpmsftngxa07.ph x.gbl!cpmsftngx a06.phx.gbl!TK2 MSFTNGP08.phx.g bl!TK2MSFTNGP09 .
phx.gblXref: cpmsftngxa07.ph x.gbl microsoft.publi c.dotnet.framew ork.aspnet:2115 67 X-Tomcat-NG: microsoft.publi c.dotnet.framew ork.aspnet
Every instance of a class (object) contains its own copy of each member variable. If you are navigating to Page 2, Page 1 is already gone, and you can't get to it any more. If you try to just create a new instance, you
getexactly that: a new instance. If you want to pass information back and forth, you should try using a Session variable, using Server. Transfer, or other such means to preserve the state that you need to access from the
nextpage.
-- Chris Jackson Software Engineer Microsoft MVP - Windows Client Windows XP Associate Expert -- More people read the newsgroups than read my email. Reply to the newsgroup for a faster response. (Control-G using Outlook Express) --
"ajaymehra" <aj************ **@mail.mcse.ms > wrote in message news:aj******* *******@mail.mc se.ms... Hi all, I have a class file called Properties.vb in which I define a public property as follows ----------------------------------------------------------- Public Class Properties Private CalSelectedDate As Date = Now()
Public Property CalSelDate() As Date Get Return CalSelectedDate End Get Set(ByVal Value As Date) CalSelectedDate = Value End Set End Property
End Class -----------------------------------------------------------
Now I have Page1.aspx where I create an object of Properties class and set the property value. I also have Page2.aspx where I create another object of Properies class and try to access the property value - But I dont get it.
Im guessing this is because each object I create has its own memory space... So how would I be able to accomplish this ? How do I get values from another class ?
TIA, AJ
ajaymehra ------------------------------------------------------------------------ Posted via http://www.mcse.ms ------------------------------------------------------------------------ View this thread: http://www.mcse.ms/message409039.html
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Hal Vaughan |
last post by:
I think a lot of this is definately a question of personal programming
style, but I'm new to Java and would like to hear a few opinions.
I'm writing a control panel for an application that runs separately. The
control panel is basically (almost) fully self contained. It consists of a
tabbed pane with 5 different tabs. Each tab has a number of different
controls -- basically all the "commonly used" controls (buttons, lists,
comboboxes,...
|
by: Gonçalo Rodrigues |
last post by:
Hi,
For error processing I found convenient maintaining a dictionary where
the keys are exception *classes* and the values are callables. Of
course, for this to work, exception classes have to be hashable which
I happily found that they were. So my question is, can I count on this
behaviour? Or is this behaviour I should not count on? (I found
nothing on the docs about it, thus the question).
With my best regards,
|
by: Jon Slaughter |
last post by:
I have a class that is basicaly duplicated throughout several files with
only members names changing according to the class name yet with virtually
the exact same coding going on.
e.g.
class A
{
std::vector<B*> Bs;
public:
|
by: mlimber |
last post by:
This is a repost (with slight modifications) from
comp.lang.c++.moderated in an effort to get some response.
I am using Loki's Factory as presented in _Modern C++ Design_ for
message passing in an embedded environment with multiple processors. I
created a policy for classes, which, I had hoped, would automatically
register the class with the appropriate factory:
// In some header file...
#include <cassert>
|
by: Random |
last post by:
I'm confused about the proper use and usefulness of namespaces. I beleive I
understand the purpose is so the developer can put classes within namespaces
to essentially organize your code. And I understand that you declare your
intention to use a namespace within a page through the "Inherits" attribute.
I know that using "Inherits" isn't absolutely necessary, it's just
recommended so the developer doesn't have to type out the entire...
| |
by: rodchar |
last post by:
Hey all,
I'm trying to understand Master/Detail concepts in VB.NET. If I do a data
adapter fill for both customer and orders from Northwind where should that
dataset live?
What client is responsible for instantiating the orders class? Would it be
the ui layer or the master class in the business layer?
thanks,
|
by: jojobar |
last post by:
Hello,
I am trying to use vs.net 2005 to migrate a project originally in vs.net
2003. I started with creation of a "web site", and then created folders for
each component of the site.
I read somewhere that each folder under the "web site" is compiled in
separate assembly. I however, did not find that the "web site" creation in
vs.net 2005 created any AssemblyInfo.cs file.
|
by: Peter Oliphant |
last post by:
I just discovered that the ImageList class can't be inherited. Why? What
could go wrong? I can invision a case where someone would like to add, say,
an ID field to an ImageList, possible so that the individual elements in an
array of ImageList's could be identified by the ID, thereby allowing
re-ordering the array without harm. A person could identify by index into
the array, but that would not be preserved by re-ordering (and re-ordering...
|
by: tshad |
last post by:
I am playing with Inheritance and want to make sure I understand it.
I have the following Classes:
*******************************************
Public Class AuthHeader:Inherits SoapHeader
Public AuthHeaderName As String
Public SessionKey As String = "Default"
End Class
Public Class ServiceTicket:Inherits AuthHeader
|
by: heddy |
last post by:
I have an array of objects. When I use Array.Resize<T>(ref Object,int
Newsize); and the newsize is smaller then what the array was
previously, are the resources allocated to the objects that are now
thown out of the array released properly by the CLI?
|
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,...
| |
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...
|
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...
|
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...
|
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();...
|
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...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
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: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |