473,396 Members | 2,061 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,396 software developers and data experts.

Dynamic Delegates.

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
2 1229
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Nate | last post by:
Help please, I need a genius!!! I have an application that loads assemblies at runtime. These assemblies have many classes (objects) and some do have several delegates. I want to be able to...
4
by: LP | last post by:
Hello! I am still transitioning from VB.NET to C#. I undertand the basic concepts of Delegates, more so of Events and somewhat understand AsyncCallback methods. But I need some clarification on...
1
by: Nate | last post by:
Help please, I need a genius!!! I have an application that loads assemblies at runtime. These assemblies have many classes (objects) and some do have several delegates. I want to be able to...
4
by: Dave | last post by:
Is there a way dynamically execute a a piece of code at run-time in C#? Such as representing a custom method "UserInfo.GetEmail()" as a string and get 'evaluated" during execution and return it's...
3
by: mmmpie | last post by:
I want to be able to hand off the inner functionality of a loop to a delegate. However, I also need to be able to call one of a number of delegates based on the context of the loop ( in this case...
4
by: Zark3 | last post by:
Hi all, I was wondering if anybody could enlighten me on the possibility of dynamic casting. Or, well, whether or not I'm actually trying to do this the right way. What I have is a base class...
0
by: pjr | last post by:
Using VS2005, I dynamically create an event delegate. Code follows question. My method gets the event's parameters and passes them onto a common event handler. My delegate gets called when expected...
0
by: bharathreddy | last post by:
Delegates Here in this article I will explain about delegates in brief. Some important points about delegates. This article is meant to only those who already know delegates, it will be a quick...
69
by: raylopez99 | last post by:
They usually don't teach you in most textbooks I've seen that delegates can be used to call class methods from classes that are 'unaware' of the delegate, so long as the class has the same...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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,...
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,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.