Brad,

Since you have "control" over the page class instance in this case, you
can override the following method to do what you wish:

protected override void RaisePostBackEvent(IPostBackEventHandler
sourceControl, string eventArgument)
{
 base.RaisePostBackEvent (sourceControl, eventArgument);
}

This method is what causes a Button or LinkButton click event to fire.
The Page (base) implementation of this method simply calls
sourceControl.RaisePostBackEvent(eventArgument).  You can do whatever
checks you wish here to determine whether to delegate the call to the base
Page class or whether to do nothing and ignore the click event.  You can
look in the MSDN docs for a list of controls in the framwork that
implement the IPostBackEventHandler interface.

You can also override the RegisterRequiresRaiseEvent to look for what may
have caused the post back. The method is called after the Loading of
ViewState and before any Load events are called.  The only draw back is
that this will only be called for the Button and not the LinkButton.

Chad

On Tue, 19 Apr 2005 09:47:07 -0500, Kazmer, Brad
<[EMAIL PROTECTED]> wrote:

>A webpage holds a custom server control.   The custom server control
>holds LinkButtons.
>
>A click event is fired on one of the LinkButtons in the custom server
>control and RoutineA in the server control is called as the handler of
>this event.  Next, a delegate handler on the webpage, RoutineB, is
>called.
>
>I was hoping to add code to the webpage's Page_Load event to prevent
>both RoutineA and RoutineB from executing.
>
>(I would prefer not to mess with the custom control, but it's looking
>like I'll have to.)
>
>
>-----Original Message-----
>From: Unmoderated discussion of advanced .NET topics.
>[mailto:[EMAIL PROTECTED] On Behalf Of Chad M. Gross
>Sent: Tuesday, April 19, 2005 9:59 AM
>To: [email protected]
>Subject: Re: [ADVANCED-DOTNET] How to suppress an event
>
>
>Brad,
>
>You're not giving much to go on here.  Are we taking about:
>
>1) Supressing a custom server control from invoking one of it's public
>events that may be raised whenever the click event of a containing
>button is fired?
>
>2) Supressing a button click event from firing where the button is on a
>control wihtin your own controls collection?
>
>3) Which Page_Load are we talking about here, the Page's Page_Load, a
>control's Page_Load, etc?  Do you have control over the page load you
>care about?
>
>I just need to know if you are dealing with things like a page that has
>a control, which contains another control, that you wish to suppress.
>Or if you have control over the .aspx page and the Page class or if you
>have a control that can be dropped on any page.  The main reason is that
>there are methods that you can override at the Page level that allow you
>suppress events from firing.
>
>Chad
>
>On Mon, 18 Apr 2005 10:44:50 -0500, Kazmer, Brad
><[EMAIL PROTECTED]> wrote:
>
>>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. 162
>
>===================================
>This list is hosted by DevelopMentor�  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