CodeVerge.Net Beta


   Explore    Item Entry    Members      Register  Login  
NEWSGROUP
.NET
Algorithms-Data Structures
Asp.Net
C Plus Plus
CSharp
Database
HTML
Javascript
Linq
Other
Regular Expressions
VB.Net
XML

Free Download:




Zone: > NEWSGROUP > Asp.Net Forum > windows_hosting.hosting_open_forum Tags:
Item Type: NewsGroup Date Entered: 10/21/2005 4:53:23 PM Date Modified: Subscribers: 0 Subscribe Alert
Rate It:
(NR, 0)
XPoints: N/A Replies: 6 Views: 17 Favorited: 0 Favorite
Can Reply:  No Members Can Edit: No Online: Yes
7 Items, 1 Pages 1 |< << Go >> >|
dasein_fiasco
Asp.Net User
Clearing/Discovering Control Events10/21/2005 4:53:23 PM

0/0

I have a pretty simple question here but for the life of me I can't find any answers elsewhere.

 

Given a control, I need to unwire all events registered for that control. For example, say I have a datagrid with ItemCommand, SortCommand, PageIndexChanged, and ItemDataBound events. I need a way to clear all those events from the control. Alternatively, I need a way to inspect the control to see if those events are already registered.

 

My problem is that the control is in danger of having the events registered multiple times, so I need a way to either clear out all previously registered events, or else I need to know whether or not the events have been registered.

 

Thanks in advance for any suggestions.

master4eva
Asp.Net User
Re: Clearing/Discovering Control Events10/21/2005 7:52:34 PM

0/0

I smell a fish here in the design of your code. Isn't there any other way that you could implement your code without relying on removing function pointers?

-- Justin Lovell
dasein_fiasco
Asp.Net User
Re: Clearing/Discovering Control Events10/21/2005 8:24:53 PM

0/0

Yes, definitely. But the situation arose out of an attempt to implement an optimization trick, and I'm keen to see if it can be pulled off.

The system is architectured to use dynamic composite controls, and profiling revealed the LoadControl() function to be one of the largest bottlenecks in the code. The solution was to load the controls less often, by storing the controls in the Session and pointing to them as needed. The problem is that the events will wire up to those stored controls each time that they load, and if the control has been loaded before, the events will simply stack up on it.

There are other ways to ensure that the events wire up once and only once, but nothing that's really as simple as simply clearing the events and rewiring on each load, or inspecting the events on the control to see if they need to be wired or not.  

It's fishy insofar that it's kind of a quirky design, but it does result in substantial performance improvement, which is why it's being pursued.

 

 

master4eva
Asp.Net User
Re: Clearing/Discovering Control Events10/21/2005 8:45:59 PM

0/0

In that case, why not do something like:

private void WireEvents(SomeControl c) {
   if (this.Page.Session["ControlLoaded"] == null) {
      // attach events over here.
      this.Page.Session["ControlLoaded"] = new object();
   }
}

// ...

SomeControl c = ...;

this.WireEvents(c);


And yes, I do understand the reasoning for this fishy solution Smile [:)].
-- Justin Lovell
dasein_fiasco
Asp.Net User
Re: Clearing/Discovering Control Events10/21/2005 9:48:59 PM

0/0

What you just described was another option ? tracking whether or not the events had been wired. Alternatively, I was considering looping through the this.Events collection of the control, and removing each handler that way.

 

I suppose my question was more academic than it was essential ? is there an existing way to discover if a control has events, or to clear all such events, or else do I have to write a code snippet to handle this myself?

 

In any case, thanks for the responses. Even a simple "no" is reassuring in that I'll feel confident that I can cease pouring over msdn and google results for an answer.

master4eva
Asp.Net User
Re: Clearing/Discovering Control Events10/22/2005 7:28:05 AM

0/0

I won't say that I know of definite answer as if you could remove specific handlers from events. There is no full solution as I know of one. You could discover which delegates are in the event list via something like this:

Delegate[] methodsToExecuteOnClick = this.button.Click.GetInvocationList();

However, that will give you pointers to the method information (ie: the method name to execute from which class). I did not suggest the above as the above operation is expensive and you were after performance Wink [;)].

That is the discovery method that I know of. However, I don't think you could remove it at all because I have the following scholar reasoning: adding delegates to an event should not allow another part of the application to remove it from the event. It is impractical as you may want the same delegate to be published twice (remember that list that you can only find which delegates have been added; not which object instance each one lives under).
-- Justin Lovell
dasein_fiasco
Asp.Net User
Re: Clearing/Discovering Control Events10/22/2005 1:28:16 PM

0/0

I think I solved the problem in the following manner. In the Page_Load of my controls, I invoke the following code prior to wiring/rewiring events: this.Events.Dispose(). On first glance it seems to work beautifully.
7 Items, 1 Pages 1 |< << Go >> >|


Free Download:

Books:
Teach Yourself Visual C++ 5 in 21 Days: Learn to write programming events and controls. Discover visual design and code writing techniques. Authors: Ori Gurewich, Nathan Gurewich, Pages: 799, Published: 1997
Deciphering Elizabethan Fiction Authors: Reid Barbour, Pages: 175, Published: 1993
Discovering the Americas: The Evolution of Canadian Foreign Policy Towards Latin America Authors: James Rochlin, James Francis Rochlin, Pages: 300, Published: 1994
Sams Teach Yourself Visual Basic 2005 in 24 Hours: Complete Starter Kit Authors: James D. Foxall, Pages: 536, Published: 2006
Health Psychology: Biopsychosocial Interactions Authors: Edward P. Sarafino, Pages: 579, Published: 1998
The Yoga Tradition: Its History, Literature, Philosophy and Practice Authors: Georg Feuerstein, Ken Wilber, Pages: 720, Published: 2002
Research and Knowledge at Work: Perspectives, Case-studies and Innovative Strategies Authors: John Garrick, Carl Rhodes, Pages: 285, Published: 2000
Corporate Assessment: Auditing a Company's Personality Authors: Adrian Furnham, Barrie Gunter, Pages: 293, Published: 1993

Web:
Scientists Discover Structure of Gateways to Gene Control | Eberly ... Mar 29, 2007 ... Also for the first time, researchers now have a clear picture of how ... Another discovery is that transcription-control centers tend to be ...
Clear Dreaming - 3 Guides to Dream Control - Discover Ways to ... Can you imagine the endless possibilities of what you could do if you had the pwer to choose what you can do when you are dreaming? What would you choose?
Educational Toys | Remote Control Toys | Discovery Online Toy Store We offer educational toys & games, toys that help kids learn and grow, and a wide selection of remote control toys. Discover our complete collection of ...
"I LOVE MONEY" - Chennai Workshop - Discover the Ultimate Secrets ... Sep 19, 2008 ... How to organize, Manage, control and Handle Money perfectly ... Applying clear systems of Money, Wealth Creation all through your life to ...
Scientists Discover Plants Can Control Weather May 13, 2008 ... Strip the Amazon basin & the Appalachian mountains clear of vegetation ... that reference Scientists Discover Plants Can Control Weather: ...
Discovering .NET Control.ModifierKeys. To make interface more WPF compatible I just converted ... To do this I used SENS events. And then I noticed that numbers are to big. ...
Scientists Discover “Volume Control” for Connections between Brain ... Scientists Discover “Volume Control” for Connections between Brain Regions ... The benefit of being 1000 times smaller than a human brain becomes clear when ...
Drug Discovery Today: Technologies : Proteomics: how to control ... 1b represents an early event in the stem cell differentiation, ... Multidimensional LC–MS methods have high-throughput and clear advantages for small ...
Market Clearing Price Discovery in a Single and Double-Side ... This paper has presented a Market Clearing Price discovery ... Control, Second Edition published by John Wiley and Sons, New York,. January 1996. ...
Law of Attraction - Discover 2 Simple Steps to Clear Your Negative ... Jun 15, 2007 ... Law of Attraction - Discover 2 Simple Steps to Clear Your Negative ... trust, calm) emotions to change is perspective of the event. ...

Videos:
Windows XP Tweak - Clearing services for better performance This will make your PC's performance a little better by clearing unused services you do not need. Go to start - Control panel Administrative tools -...
Missing Links Now you will discover the definitive truth about 9/11 and learn why even the most popular movies on the subject have failed to address the evidence e...
Zack & Wiki: Quest for Barbaros' Treasure In this game, you are in control of a cute little pirate named Zack who's out to solve puzzles and discover the legendary treasure that was hidden aw...
Doctor Who - The Invisible Opiate [Episode One] Still shaken over the death of companion Leia, and in need of convalescence, the Doctor suggests that he and his new companion, Charlotte, travel to ...
Zack & Wiki: Quest for Barbaros' Treasure In this game, you are in control of a cute little pirate named Zack who's out to solve puzzles and discover the legendary treasure that was hidden aw...
9/11 Missing Links: The Enemy Within pt.1/12 Now you will discover the definitive truth about 9/11 and learn why even the most popular movies on the subject have failed to address the evidence e...
BIODERMAZEN SCAM? WHAT PEOPLE REALLY HAVE TO SAY GOOD.. Biodermazen oral tablets is it a scam?? http://www.squidoo.com/biodermazen-ac... Have you been doing some research on google about the product Biode...
Missing Links Now you will discover the definitive truth about 9/11 and learn why even the most popular movies on the subject have failed to address the evidence e...
9/11 Missing Links: The Enemy Within pt.2/12 Now you will discover the definitive truth about 9/11 and learn why even the most popular movies on the subject have failed to address the evidence e...
Discovery Series - Getting at the root of sex abuse: Treatment and Prevention The solution to solving most cases of sex abuse problem in America is to move towards prevention and treatment as the first line of defense. Educ...




Search This Site:










system upgrades

checkbox database

javascript in a custom module

create dropdown extender at runtime

how do i determine the path to the current folder?

newbie httpwebresponse problem

including a .html file inside the aspx file

custom control: using connectionstringeditor in smart tag crashes visual studio

application_start in asp.net 2 - how does it work?

question w/ ms data access application block

core module abstraction in 3.1 - another idea

how web service contact a active directory using ssl???

module permission

problem with solpart child menu

simple question

database is not building

dnn 2.0+ with oracle

problem using allowclose/allowminimize

defaultbutton on htmlform control

converting a 2.x skin to 3.x

how can i print a specified url page from my aspx page?

error accessing webadmin

update excel on web

anyone knows the english version of this link?

how to set dnn url control's root directory

background color transparent

populating dropdownlist with dates

rich text box

asp.net and error 404 page cannot be found

calling all safari browsers

 
All Times Are GMT