By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,247 Members | 1,018 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,247 IT Pros & Developers. It's quick & easy.

Viewstate of variables.

P: n/a
Been a while since I've touched asp.net but one thing that always seems to
fustrate me is the loss of state on variable declarations. Is there anyway
(i.e. assigning an attribute etc) to instruct the server to remember a
variables state *without* having to go through the rigmarole of saving and
loading to and from the Session state manually or similar workaround for any
Types (including custom types) in exactly the same way web controls retain
state. I understand the reasons (performance) that this is not done by
default ... but it is really anoying.

e.g. This would be great...

[ViewState save=true]
protected Person myperson;

private void Page_Load(object sender, System.EventArgs e) {
if (!this.IsPostBack)
myperson = new Person("Mr Unhappy");
}
//otherwise myperson still points to an instance
}
so that on every postback myperson instance would still exist.

Any ideas are extremely welcome.
Br,

Mark.
Nov 19 '05 #1
Share this Question
Share on Google+
9 Replies


P: n/a
This is a perfect candidate for a property.

I type:

protected Person myPerson;

Then I run a macro that turns the above code into:

protected Person myPerson
{
get {
Person p = ViewState["Person"] as Person;
if ( p == null ) {
p = new Person( "Mr Happy I don't have to type this every time." );
ViewState["Person"] = value;
}
return p;
}

set { ViewState["Person"] = value; }
}

In code I only reference myPerson. You can also continue to set it in
Page.Load !PostBack and leave out the new declaration in the property.

"Mark Broadbent" <no****@nospam.com> wrote in message
news:OZ**************@TK2MSFTNGP15.phx.gbl...
Been a while since I've touched asp.net but one thing that always seems to
fustrate me is the loss of state on variable declarations. Is there anyway
(i.e. assigning an attribute etc) to instruct the server to remember a
variables state *without* having to go through the rigmarole of saving and
loading to and from the Session state manually or similar workaround for any Types (including custom types) in exactly the same way web controls retain
state. I understand the reasons (performance) that this is not done by
default ... but it is really anoying.

e.g. This would be great...

[ViewState save=true]
protected Person myperson;

private void Page_Load(object sender, System.EventArgs e) {
if (!this.IsPostBack)
myperson = new Person("Mr Unhappy");
}
//otherwise myperson still points to an instance
}
so that on every postback myperson instance would still exist.

Any ideas are extremely welcome.
Br,

Mark.

Nov 19 '05 #2

P: n/a
You can store any variable in ViewState that can be serialized as text.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
Ambiguity has a certain quality to it.

"Mark Broadbent" <no****@nospam.com> wrote in message
news:OZ**************@TK2MSFTNGP15.phx.gbl...
Been a while since I've touched asp.net but one thing that always seems to
fustrate me is the loss of state on variable declarations. Is there anyway
(i.e. assigning an attribute etc) to instruct the server to remember a
variables state *without* having to go through the rigmarole of saving and
loading to and from the Session state manually or similar workaround for
any Types (including custom types) in exactly the same way web controls
retain state. I understand the reasons (performance) that this is not done
by default ... but it is really anoying.

e.g. This would be great...

[ViewState save=true]
protected Person myperson;

private void Page_Load(object sender, System.EventArgs e) {
if (!this.IsPostBack)
myperson = new Person("Mr Unhappy");
}
//otherwise myperson still points to an instance
}
so that on every postback myperson instance would still exist.

Any ideas are extremely welcome.
Br,

Mark.

Nov 19 '05 #3

P: n/a
You are having to explicitly implement coding to manage the state of this
variable and we are talking more than a couple of lines -especially when the
instance variable in question is quite complex such as when it has method
calls which change its state (that must be saved).

Thanks for suggestion though - it is probably the cleanest way to do this
(as I unfortunately thought).

Br,

Mark.
"William F. Robertson, Jr." <th****@nameht.org> wrote in message
news:e7**************@TK2MSFTNGP15.phx.gbl...
This is a perfect candidate for a property.

I type:

protected Person myPerson;

Then I run a macro that turns the above code into:

protected Person myPerson
{
get {
Person p = ViewState["Person"] as Person;
if ( p == null ) {
p = new Person( "Mr Happy I don't have to type this every time." );
ViewState["Person"] = value;
}
return p;
}

set { ViewState["Person"] = value; }
}

In code I only reference myPerson. You can also continue to set it in
Page.Load !PostBack and leave out the new declaration in the property.

"Mark Broadbent" <no****@nospam.com> wrote in message
news:OZ**************@TK2MSFTNGP15.phx.gbl...
Been a while since I've touched asp.net but one thing that always seems
to
fustrate me is the loss of state on variable declarations. Is there
anyway
(i.e. assigning an attribute etc) to instruct the server to remember a
variables state *without* having to go through the rigmarole of saving
and
loading to and from the Session state manually or similar workaround for

any
Types (including custom types) in exactly the same way web controls
retain
state. I understand the reasons (performance) that this is not done by
default ... but it is really anoying.

e.g. This would be great...

[ViewState save=true]
protected Person myperson;

private void Page_Load(object sender, System.EventArgs e) {
if (!this.IsPostBack)
myperson = new Person("Mr Unhappy");
}
//otherwise myperson still points to an instance
}
so that on every postback myperson instance would still exist.

Any ideas are extremely welcome.
Br,

Mark.


Nov 19 '05 #4

P: n/a
Hi Kevin, thanks but unfortunately I still feel that something is lacking a
bit. Being forced to programmatically implement state management on
something simple (for instance a protected value type e.g. protected int
num) when the functionality/ ability could be there via attributes or
something similar I just find a bit crazy and fustrates me immensely because
it potentially can cause many bugs if not handled correctly especially
someone like me who spends more time on Winforms than asp.net.

MS give us self-state mangaged (or as near as damn it) Web Controls, yet
still force us to implement state management for class level vars.
Am I asking for too much (as per my origonal post) to be able to specify
this for serializable objects? It would bring Web forms programming so much
closer to that of Winforms.

Br,

Mark.

"Kevin Spencer" <ke***@DIESPAMMERSDIEtakempis.com> wrote in message
news:eS**************@TK2MSFTNGP12.phx.gbl...
You can store any variable in ViewState that can be serialized as text.

--
HTH,

Kevin Spencer
Microsoft MVP
.Net Developer
Ambiguity has a certain quality to it.

"Mark Broadbent" <no****@nospam.com> wrote in message
news:OZ**************@TK2MSFTNGP15.phx.gbl...
Been a while since I've touched asp.net but one thing that always seems
to fustrate me is the loss of state on variable declarations. Is there
anyway (i.e. assigning an attribute etc) to instruct the server to
remember a variables state *without* having to go through the rigmarole
of saving and loading to and from the Session state manually or similar
workaround for any Types (including custom types) in exactly the same way
web controls retain state. I understand the reasons (performance) that
this is not done by default ... but it is really anoying.

e.g. This would be great...

[ViewState save=true]
protected Person myperson;

private void Page_Load(object sender, System.EventArgs e) {
if (!this.IsPostBack)
myperson = new Person("Mr Unhappy");
}
//otherwise myperson still points to an instance
}
so that on every postback myperson instance would still exist.

Any ideas are extremely welcome.
Br,

Mark.


Nov 19 '05 #5

P: n/a
The code snippet by far does NOT manage the state of myPerson. The only
thing explicit about it, is I am explicitly storing the item in ViewState.
I could have placed it in Session, Application, Cache, or could have
implemented explicit state management.

ViewState["Person"] points to an instance of myPerson.
Person points to the same instance.

Because ViewState["Person"] points to an instance, no matter how complex
your methods calls are on it, your Person is not actually saved to ViewState
until PreRender. You can make all the changes you want to the internal
workings of your Person object, without reassigning it to ViewState.

How would you expected to have this item persisted?

bill
"Mark Broadbent" <no****@nospam.com> wrote in message
news:eQ****************@TK2MSFTNGP10.phx.gbl...
You are having to explicitly implement coding to manage the state of this
variable and we are talking more than a couple of lines -especially when the instance variable in question is quite complex such as when it has method
calls which change its state (that must be saved).

Thanks for suggestion though - it is probably the cleanest way to do this
(as I unfortunately thought).

Br,

Mark.
"William F. Robertson, Jr." <th****@nameht.org> wrote in message
news:e7**************@TK2MSFTNGP15.phx.gbl...
This is a perfect candidate for a property.

I type:

protected Person myPerson;

Then I run a macro that turns the above code into:

protected Person myPerson
{
get {
Person p = ViewState["Person"] as Person;
if ( p == null ) {
p = new Person( "Mr Happy I don't have to type this every time." );
ViewState["Person"] = value;
}
return p;
}

set { ViewState["Person"] = value; }
}

In code I only reference myPerson. You can also continue to set it in
Page.Load !PostBack and leave out the new declaration in the property.

"Mark Broadbent" <no****@nospam.com> wrote in message
news:OZ**************@TK2MSFTNGP15.phx.gbl...
Been a while since I've touched asp.net but one thing that always seems
to
fustrate me is the loss of state on variable declarations. Is there
anyway
(i.e. assigning an attribute etc) to instruct the server to remember a
variables state *without* having to go through the rigmarole of saving
and
loading to and from the Session state manually or similar workaround
for any
Types (including custom types) in exactly the same way web controls
retain
state. I understand the reasons (performance) that this is not done by
default ... but it is really anoying.

e.g. This would be great...

[ViewState save=true]
protected Person myperson;

private void Page_Load(object sender, System.EventArgs e) {
if (!this.IsPostBack)
myperson = new Person("Mr Unhappy");
}
//otherwise myperson still points to an instance
}
so that on every postback myperson instance would still exist.

Any ideas are extremely welcome.
Br,

Mark.



Nov 19 '05 #6

P: n/a
Hi Mark,
... Being forced to programmatically implement state management on
something simple (for instance a protected value type e.g. protected int
num) when the functionality/ ability could be there via attributes or
something similar ...
I've been doing web applications for about 10 years now, and have never
thought of it as "simple." In fact, web application development is an order
of magnitude more complex that Windows Forms porogramming, "simply" ( ;-) )
because it works in an HTTP stateless web environment, and on the big bad
Internet, where security is a major player, not to mention all of the other
networking issues involved.
Am I asking for too much (as per my origonal post) to be able to specify
this for serializable objects?
Under the circumstances (as I described in my previous paragraph) I would
have to say "yes."

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
Ambiguity has a certain quality to it.

"Mark Broadbent" <no****@nospam.com> wrote in message
news:%2****************@TK2MSFTNGP14.phx.gbl... Hi Kevin, thanks but unfortunately I still feel that something is lacking
a bit. Being forced to programmatically implement state management on
something simple (for instance a protected value type e.g. protected int
num) when the functionality/ ability could be there via attributes or
something similar I just find a bit crazy and fustrates me immensely
because it potentially can cause many bugs if not handled correctly
especially someone like me who spends more time on Winforms than asp.net.

MS give us self-state mangaged (or as near as damn it) Web Controls, yet
still force us to implement state management for class level vars.
Am I asking for too much (as per my origonal post) to be able to specify
this for serializable objects? It would bring Web forms programming so
much closer to that of Winforms.

Br,

Mark.

"Kevin Spencer" <ke***@DIESPAMMERSDIEtakempis.com> wrote in message
news:eS**************@TK2MSFTNGP12.phx.gbl...
You can store any variable in ViewState that can be serialized as text.

--
HTH,

Kevin Spencer
Microsoft MVP
.Net Developer
Ambiguity has a certain quality to it.

"Mark Broadbent" <no****@nospam.com> wrote in message
news:OZ**************@TK2MSFTNGP15.phx.gbl...
Been a while since I've touched asp.net but one thing that always seems
to fustrate me is the loss of state on variable declarations. Is there
anyway (i.e. assigning an attribute etc) to instruct the server to
remember a variables state *without* having to go through the rigmarole
of saving and loading to and from the Session state manually or similar
workaround for any Types (including custom types) in exactly the same
way web controls retain state. I understand the reasons (performance)
that this is not done by default ... but it is really anoying.

e.g. This would be great...

[ViewState save=true]
protected Person myperson;

private void Page_Load(object sender, System.EventArgs e) {
if (!this.IsPostBack)
myperson = new Person("Mr Unhappy");
}
//otherwise myperson still points to an instance
}
so that on every postback myperson instance would still exist.

Any ideas are extremely welcome.
Br,

Mark.



Nov 19 '05 #7

P: n/a
I'm afraid you've lost me a bit with what you have said (doesn't quite make
sense ...to me at least)
I completely understand using the state management techiques (so not a
problem there). Calling methods on the object saved in view state via
property is effectively making a copy of that serialized instance to memory
so that if i did the following for a collection object stored in viewstate
and accessed via property BigCollection....

BigCollection.MoveToRecord(10);

will only perform that operation on the "instance" returned/ deserialized
via the property from viewstate.
It will not perform that operation on the serialized instance stored in
viewstate. I would explicitly have to make sure that I overwrote that item
thus...

ACollection col;
col = BigCollection;
col.MoveToRecord(10);
BigCollection = col;

As you say, I know that I don't *have* to reassign it to ViewState if I
don't want changes to be written back, but that is exactly what I need.

My suggestion in my original post is simply that Web Controls perform their
own state management and that makes things easy (the whole reason MS
introduced them), I just thought that it should be possible to "mark"
variables valuetypes and reftype objects (that can be serialized) to force
asp.net to persist them -if we wanted.

This would surely make state management so much easier to do, less code to
write and less scope for bugs.

Thanks,

Mark.
"William F. Robertson, Jr." <th****@nameht.org> wrote in message
news:e1**************@TK2MSFTNGP09.phx.gbl...
The code snippet by far does NOT manage the state of myPerson. The only
thing explicit about it, is I am explicitly storing the item in ViewState.
I could have placed it in Session, Application, Cache, or could have
implemented explicit state management.

ViewState["Person"] points to an instance of myPerson.
Person points to the same instance.

Because ViewState["Person"] points to an instance, no matter how complex
your methods calls are on it, your Person is not actually saved to
ViewState
until PreRender. You can make all the changes you want to the internal
workings of your Person object, without reassigning it to ViewState.

How would you expected to have this item persisted?

bill
"Mark Broadbent" <no****@nospam.com> wrote in message
news:eQ****************@TK2MSFTNGP10.phx.gbl...
You are having to explicitly implement coding to manage the state of this
variable and we are talking more than a couple of lines -especially when

the
instance variable in question is quite complex such as when it has method
calls which change its state (that must be saved).

Thanks for suggestion though - it is probably the cleanest way to do this
(as I unfortunately thought).

Br,

Mark.
"William F. Robertson, Jr." <th****@nameht.org> wrote in message
news:e7**************@TK2MSFTNGP15.phx.gbl...
> This is a perfect candidate for a property.
>
> I type:
>
> protected Person myPerson;
>
> Then I run a macro that turns the above code into:
>
> protected Person myPerson
> {
> get {
> Person p = ViewState["Person"] as Person;
> if ( p == null ) {
> p = new Person( "Mr Happy I don't have to type this every
> time." );
> ViewState["Person"] = value;
> }
> return p;
> }
>
> set { ViewState["Person"] = value; }
> }
>
> In code I only reference myPerson. You can also continue to set it in
> Page.Load !PostBack and leave out the new declaration in the property.
>
> "Mark Broadbent" <no****@nospam.com> wrote in message
> news:OZ**************@TK2MSFTNGP15.phx.gbl...
>> Been a while since I've touched asp.net but one thing that always
>> seems
>> to
>> fustrate me is the loss of state on variable declarations. Is there
>> anyway
>> (i.e. assigning an attribute etc) to instruct the server to remember a
>> variables state *without* having to go through the rigmarole of saving
>> and
>> loading to and from the Session state manually or similar workaround for > any
>> Types (including custom types) in exactly the same way web controls
>> retain
>> state. I understand the reasons (performance) that this is not done by
>> default ... but it is really anoying.
>>
>> e.g. This would be great...
>>
>> [ViewState save=true]
>> protected Person myperson;
>>
>> private void Page_Load(object sender, System.EventArgs e) {
>> if (!this.IsPostBack)
>> myperson = new Person("Mr Unhappy");
>> }
>> //otherwise myperson still points to an instance
>> }
>>
>>
>> so that on every postback myperson instance would still exist.
>>
>> Any ideas are extremely welcome.
>> Br,
>>
>> Mark.
>>
>>
>
>



Nov 19 '05 #8

P: n/a
I agree with all you say *except* the last bit :)
If it can be done with web controls, it can be done with anything
(serializable).

I guess if the Earth was round I'd like it flat ......oh wait a minute ;-)

"Kevin Spencer" <ke***@DIESPAMMERSDIEtakempis.com> wrote in message
news:uD**************@tk2msftngp13.phx.gbl...
Hi Mark,
... Being forced to programmatically implement state management on
something simple (for instance a protected value type e.g. protected int
num) when the functionality/ ability could be there via attributes or
something similar ...


I've been doing web applications for about 10 years now, and have never
thought of it as "simple." In fact, web application development is an
order of magnitude more complex that Windows Forms porogramming, "simply"
( ;-) ) because it works in an HTTP stateless web environment, and on the
big bad Internet, where security is a major player, not to mention all of
the other networking issues involved.
Am I asking for too much (as per my origonal post) to be able to specify
this for serializable objects?


Under the circumstances (as I described in my previous paragraph) I would
have to say "yes."

--
HTH,

Kevin Spencer
Microsoft MVP
.Net Developer
Ambiguity has a certain quality to it.

"Mark Broadbent" <no****@nospam.com> wrote in message
news:%2****************@TK2MSFTNGP14.phx.gbl...
Hi Kevin, thanks but unfortunately I still feel that something is lacking
a bit. Being forced to programmatically implement state management on
something simple (for instance a protected value type e.g. protected int
num) when the functionality/ ability could be there via attributes or
something similar I just find a bit crazy and fustrates me immensely
because it potentially can cause many bugs if not handled correctly
especially someone like me who spends more time on Winforms than asp.net.

MS give us self-state mangaged (or as near as damn it) Web Controls, yet
still force us to implement state management for class level vars.
Am I asking for too much (as per my origonal post) to be able to specify
this for serializable objects? It would bring Web forms programming so
much closer to that of Winforms.

Br,

Mark.

"Kevin Spencer" <ke***@DIESPAMMERSDIEtakempis.com> wrote in message
news:eS**************@TK2MSFTNGP12.phx.gbl...
You can store any variable in ViewState that can be serialized as text.

--
HTH,

Kevin Spencer
Microsoft MVP
.Net Developer
Ambiguity has a certain quality to it.

"Mark Broadbent" <no****@nospam.com> wrote in message
news:OZ**************@TK2MSFTNGP15.phx.gbl...
Been a while since I've touched asp.net but one thing that always seems
to fustrate me is the loss of state on variable declarations. Is there
anyway (i.e. assigning an attribute etc) to instruct the server to
remember a variables state *without* having to go through the rigmarole
of saving and loading to and from the Session state manually or similar
workaround for any Types (including custom types) in exactly the same
way web controls retain state. I understand the reasons (performance)
that this is not done by default ... but it is really anoying.

e.g. This would be great...

[ViewState save=true]
protected Person myperson;

private void Page_Load(object sender, System.EventArgs e) {
if (!this.IsPostBack)
myperson = new Person("Mr Unhappy");
}
//otherwise myperson still points to an instance
}
so that on every postback myperson instance would still exist.

Any ideas are extremely welcome.
Br,

Mark.



Nov 19 '05 #9

P: n/a
This would be much easier to explain with a chalkboard, but I will try to
make it understandable. I think you are a little confused on when an object
is "copyed" and when a reference to an object is copyed.

I am fluffing a little bit on the details to get the point across. This
following assumes that BigCollection is the property using the pattern
discussed earlier.

ViewState is a string keyed collection. The key is a string and the value
is an object reference to an actual object.

ViewState is only serialized on SaveViewState and Deserialized on
LoadViewState. When the ViewState is deserialized the text is converted
into a real object and the object reference is saved in the ViewState
StateBag. When you access ViewState["BigCollection"] you are NOT
deserializing the object, the object is already deserialized and is sitting
on the managed heap.

Since all class instances are basically pointers was this means is
ViewState["BigCollection"] points to heap address 0x01234567.
When accessing the BigCollection property it points to heap address
0x01234567.

No matter what methods you call on it, ie MoveToRecord(10), the address of
BigCollection never changed. You can not change the "this" pointer of an
object.

Even when you assigned BigCollection to another pointer.

Collection col = BigCollection.

col still points to heap address 0x01234567.

So in your snippet below when you assign col back to BigCollection, you are
replacing nothing. It is the same thing as
int a = 7;
a = 7.

The value of A did not change.

BigCollection, ViewState["BigCollection"], and col all point to the same
location.

So when the SaveViewState method is called and the serialization takes
place, all changes made to heap address 0x1234567 will be inforce and
updated correctly.

bill

FYI, this is nearly the same model the WebControls implement in their state
mechanism.

"Mark Broadbent" <no****@nospam.com> wrote in message
news:eN**************@TK2MSFTNGP10.phx.gbl...
I'm afraid you've lost me a bit with what you have said (doesn't quite make sense ...to me at least)
I completely understand using the state management techiques (so not a
problem there). Calling methods on the object saved in view state via
property is effectively making a copy of that serialized instance to memory so that if i did the following for a collection object stored in viewstate
and accessed via property BigCollection....

BigCollection.MoveToRecord(10);

will only perform that operation on the "instance" returned/ deserialized
via the property from viewstate.
It will not perform that operation on the serialized instance stored in
viewstate. I would explicitly have to make sure that I overwrote that item
thus...

ACollection col;
col = BigCollection;
col.MoveToRecord(10);
BigCollection = col;

As you say, I know that I don't *have* to reassign it to ViewState if I
don't want changes to be written back, but that is exactly what I need.

My suggestion in my original post is simply that Web Controls perform their own state management and that makes things easy (the whole reason MS
introduced them), I just thought that it should be possible to "mark"
variables valuetypes and reftype objects (that can be serialized) to force
asp.net to persist them -if we wanted.

This would surely make state management so much easier to do, less code to
write and less scope for bugs.

Thanks,

Mark.
"William F. Robertson, Jr." <th****@nameht.org> wrote in message
news:e1**************@TK2MSFTNGP09.phx.gbl...
The code snippet by far does NOT manage the state of myPerson. The only
thing explicit about it, is I am explicitly storing the item in ViewState. I could have placed it in Session, Application, Cache, or could have
implemented explicit state management.

ViewState["Person"] points to an instance of myPerson.
Person points to the same instance.

Because ViewState["Person"] points to an instance, no matter how complex
your methods calls are on it, your Person is not actually saved to
ViewState
until PreRender. You can make all the changes you want to the internal
workings of your Person object, without reassigning it to ViewState.

How would you expected to have this item persisted?

bill
"Mark Broadbent" <no****@nospam.com> wrote in message
news:eQ****************@TK2MSFTNGP10.phx.gbl...
You are having to explicitly implement coding to manage the state of this variable and we are talking more than a couple of lines -especially when
the
instance variable in question is quite complex such as when it has

method calls which change its state (that must be saved).

Thanks for suggestion though - it is probably the cleanest way to do this (as I unfortunately thought).

Br,

Mark.
"William F. Robertson, Jr." <th****@nameht.org> wrote in message
news:e7**************@TK2MSFTNGP15.phx.gbl...
> This is a perfect candidate for a property.
>
> I type:
>
> protected Person myPerson;
>
> Then I run a macro that turns the above code into:
>
> protected Person myPerson
> {
> get {
> Person p = ViewState["Person"] as Person;
> if ( p == null ) {
> p = new Person( "Mr Happy I don't have to type this every
> time." );
> ViewState["Person"] = value;
> }
> return p;
> }
>
> set { ViewState["Person"] = value; }
> }
>
> In code I only reference myPerson. You can also continue to set it in > Page.Load !PostBack and leave out the new declaration in the property. >
> "Mark Broadbent" <no****@nospam.com> wrote in message
> news:OZ**************@TK2MSFTNGP15.phx.gbl...
>> Been a while since I've touched asp.net but one thing that always
>> seems
>> to
>> fustrate me is the loss of state on variable declarations. Is there
>> anyway
>> (i.e. assigning an attribute etc) to instruct the server to remember a >> variables state *without* having to go through the rigmarole of saving >> and
>> loading to and from the Session state manually or similar workaround

for
> any
>> Types (including custom types) in exactly the same way web controls
>> retain
>> state. I understand the reasons (performance) that this is not done by >> default ... but it is really anoying.
>>
>> e.g. This would be great...
>>
>> [ViewState save=true]
>> protected Person myperson;
>>
>> private void Page_Load(object sender, System.EventArgs e) {
>> if (!this.IsPostBack)
>> myperson = new Person("Mr Unhappy");
>> }
>> //otherwise myperson still points to an instance
>> }
>>
>>
>> so that on every postback myperson instance would still exist.
>>
>> Any ideas are extremely welcome.
>> Br,
>>
>> Mark.
>>
>>
>
>



Nov 19 '05 #10

This discussion thread is closed

Replies have been disabled for this discussion.