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

Dynamic Delegates.

P: n/a
I had a requirement to code dynamic delegates, so they attach detach from
the button as needed ... then after time realised that the button is not
retaining it's click handlers. To circumvent this I am saving a enum value
to viewstate to tell the load event what delegates handlers to attach on
each postback.

As far as I am concerned I shouldn't need to do this. The button should
retain the state of what handlers have been assigned to it.

Anyone else agree?

Br,

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


P: n/a
The Delegates, when you think about it, are not values, but an array of
memory addresses. Therefore you can't save a handler's address for some
unknown amount of time that then use that value again later since the stack
could be moving around.

What this means is that delegates and events are not serializable and
therefore can not be placed inside of a viewstate. You've got the perfect
solution right now.

"Mark Broadbent" <no****@nospam.com> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
I had a requirement to code dynamic delegates, so they attach detach from
the button as needed ... then after time realised that the button is not
retaining it's click handlers. To circumvent this I am saving a enum value
to viewstate to tell the load event what delegates handlers to attach on
each postback.

As far as I am concerned I shouldn't need to do this. The button should
retain the state of what handlers have been assigned to it.

Anyone else agree?

Br,

Mark.

Nov 19 '05 #2

P: n/a
Yes I guess that makes sense. Thanks for confirmation that I am at least
doing the correct workaround.

br,

Mark.

"David Jessee" <dj*****@houston.rr.com> wrote in message
news:Ow**************@tk2msftngp13.phx.gbl...
The Delegates, when you think about it, are not values, but an array of
memory addresses. Therefore you can't save a handler's address for some
unknown amount of time that then use that value again later since the
stack
could be moving around.

What this means is that delegates and events are not serializable and
therefore can not be placed inside of a viewstate. You've got the perfect
solution right now.

"Mark Broadbent" <no****@nospam.com> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
I had a requirement to code dynamic delegates, so they attach detach from
the button as needed ... then after time realised that the button is not
retaining it's click handlers. To circumvent this I am saving a enum
value
to viewstate to tell the load event what delegates handlers to attach on
each postback.

As far as I am concerned I shouldn't need to do this. The button should
retain the state of what handlers have been assigned to it.

Anyone else agree?

Br,

Mark.


Nov 19 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.