I always write my custom user controls in one of two ways.

#1 - When a condition is met, I do not do anyStuff() and instead raise
the event to the consumer who must do allStuff() themselves.  This way
if the implementation of the event changes for some reason I do not
break any contracts by moving to the new methodology.

It is also nice because it avoids the conundrum you find yourself in at
the moment.

#2 - Sometimes however, encapsulation of some code is needed for
security and/or practicality purposes.  In these cases, when a condition
is met, I do not do anyStuff() and instead raise an event with a boolean
parameter asking the user if they would to allow the default action to
take place.  If they do not they can do anyStuff() they want and merely
return false to the event and they are good to go.


R. Joe Reich
System Analyst
Comcast Communications, Inc.
Phone: 248.233.4512
Fax:   248.233.4788
Cell:  734.476.4844
Email: [EMAIL PROTECTED]
MSN:   [EMAIL PROTECTED]
 

> -----Original Message-----
> From: Brad Kazmer
> Sent: Monday, April 18, 2005 12:56 PM
> To: [email protected]
> Subject: Re: [ADVANCED-DOTNET] How to suppress an event
> 
> I can't write the "if something is true" in Event_A.
> 
> The control in question is actually a custom server
> control.  When an event fires, first the server
> control handles the event and does someStuff(), then
> a delegate handler on the webpage is called and does
> moreStuff().
> 
> If I write the "if something is true" code in Event_A
> on the webpage, then someStuff() will already have
> executed.  I would like neither someStuff() nor
> moreStuff() to execute and was thinking that there
> is a way to completely suppress the control's event
> in Page_Load.
> 
> Sorry if I should have been more specific in my
> first email.
> 
> -----Original Message-----
> From: Unmoderated discussion of advanced .NET topics.
> [mailto:[EMAIL PROTECTED] On Behalf Of James Conley
> Sent: Monday, April 18, 2005 12:09 PM
> To: [email protected]
> Subject: Re: [ADVANCED-DOTNET] How to suppress an event
> 
> 
> You know something in the Page_Load event that tells you that 
> you don't
> really want to respond to Event_A?
> 
> Will you still know that in Event_A? If so then write the handler for
> Event_A such that...
> 
> If (Something is True)
>         'do nothing
> Else
>         'regular event code
> End If
> 
> James C.
> -----Original Message-----
> From: Unmoderated discussion of advanced .NET topics.
> [mailto:[EMAIL PROTECTED] On Behalf Of Kazmer, Brad
> Sent: Monday, April 18, 2005 11:45 AM
> To: [email protected]
> Subject: How to suppress an event
> 
> In ASP.Net, a server event is triggered on a server control.  Is there
> any way to suppress the server event in the Page_Load event 
> before it is
> called?
> 
> 
> *****
> The information transmitted is intended only for the person 
> or entity to
> which it is addressed and may contain confidential, 
> proprietary, and/or
> privileged material. Any review, retransmission, 
> dissemination or other
> use of, or taking of any action in reliance upon this information by
> persons or entities other than the intended recipient is 
> prohibited. If
> you received this in error, please contact the sender and delete the
> material from all computers. 162
> 
> ===================================
> This list is hosted by DevelopMentor(r)  http://www.develop.com
> 
> View archives and manage your subscription(s) at
> http://discuss.develop.com
> 
> ===================================
> This list is hosted by DevelopMentor(r)  http://www.develop.com
> 
> View archives and manage your subscription(s) at
> http://discuss.develop.com
> 
> *****
> 
> The information transmitted is intended only for the person 
> or entity to which it is addressed and may contain 
> confidential, proprietary, and/or privileged material. Any 
> review, retransmission, dissemination or other use of, or 
> taking of any action in reliance upon this information by 
> persons or entities other than the intended recipient is 
> prohibited. If you received this in error, please contact the 
> sender and delete the material from all computers. 117
> 
> ===================================
> This list is hosted by DevelopMentor(r)  http://www.develop.com
> 
> View archives and manage your subscription(s) at 
> http://discuss.develop.com
> 

===================================
This list is hosted by DevelopMentor�  http://www.develop.com

View archives and manage your subscription(s) at http://discuss.develop.com

Reply via email to