Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 2.0 > ASP.NET 2.0 Professional
Password Reminder
Register
| FAQ | Members List | Search | Today's Posts | Mark Forums Read
ASP.NET 2.0 Professional If you are an experienced ASP.NET programmer, this is the forum for your 2.0 questions. Please also see the Visual Web Developer 2005 forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 2.0 Professional section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
 
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old May 15th, 2007, 02:30 PM
Registered User
 
Join Date: May 2007
Location: Vancouver, BC, Canada.
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to forkbeard
Default Dynamically Altering a Child Control's Method

I'm building a generic template control in C#. Among other things, this control will enumerate all of its children, adding a method call to the child's changed event where applicable. Is it possible to alter an event at run time? Probably not eh?

Ok, so I just had a bit of an epiphany and realized that I don't need to add a method call but I'd still be interested to know how one could do this.

--
Shaun
  #2 (permalink)  
Old May 15th, 2007, 06:30 PM
planoie's Avatar
Friend of Wrox
Points: 16,481, Level: 55
Points: 16,481, Level: 55 Points: 16,481, Level: 55 Points: 16,481, Level: 55
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Aug 2003
Location: Clifton Park, New York, USA.
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

I'm not sure if this is what you are looking for but...

Certainly events can be wired up at runtime. Actually, that's the ONLY time they are wired up. The code usually looks something like this:

classInstance.SomeEvent += new EventHandler(MyMethodToHandleTheEvent);

The method signature of "MyMethodToHandleTheEvent" needs to match whatever the "EventHandler" delegate is expecting and "SomeEvent" must be of type "EventHandler" in order for that to pass compilation.

If you look in the code of any application that has event handling (web form, win form) you'll see this syntax in lots of places.

-Peter
  #3 (permalink)  
Old May 15th, 2007, 07:13 PM
Registered User
 
Join Date: May 2007
Location: Vancouver, BC, Canada.
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to forkbeard
Default

Thanks a bunch! I'll give that a try tomorrow at work.

--
Shaun
 


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
dynamically created control's values to database saket123 ASP.NET 2.0 Basics 4 August 13th, 2008 12:49 AM
Altering a listbox from another form Firestorm9 C# 2005 1 July 9th, 2007 06:12 AM
how to make child dynamically gantait XSLT 1 February 23rd, 2007 06:29 AM
How to retrieve control's "Name" and "Value" in an niranjanshaiwale C# 0 September 27th, 2006 04:20 AM



All times are GMT -4. The time now is 10:23 PM.


Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.