How to Cancel a "non cancellable" Event

V

Verde

I'm using a 3rd party component in an ASP.NET 1.1 Web application. The
component has a .Click event that can be fired from the client, with an
associated event procedure in the code-behind module.

The logic in the click event procedure may, under some conditions, need to
abort further processing. AFAIK the control's event is not cancellable. At
least its EventArgs does not have any apparent support for .Cancel.

So, what can I do to completely abort further processing from within the
click event procedure (i.e., cancel the event)? Please note...

.... I cannot simply have a try/catch block and throw an exception in order
to cancel the event processing - BECAUSE when my code is finished executing
(regardless of what it does or does not do), the 3rd Party component
transferes the user to another Web site (the site of the component's
vendor). It essentially POSTs some data to the vendor's web site - and I
want to be able to abort this POST operation which is performed by the 3rd
party component after any of my code in its click event procedure executes.

Thanks!
 
J

Jan Bannister (jancsharp.blogspot.com)

Hey Verde,

If you're trying to circumvent the components licencing you won't get
much help here.

Just my 2 pence
Jan
 
V

Verde

You read way too much into my post while obviously not reading it carefully.

FWIW: This component is *free* and I'm just trying to work around a
shortcoming of the vendor. Trying to cancel an event to *prevent* the
primary and fundamental functionality of the component - BY DEFINITION - is
NOT me trying to get that functionality to happen for free. I'm trying to
get it to NOT happen under certain runtime conditions. They provided a click
event in their component that is not cancellable - thereby presenting a
slippery slope for my users. Once they click it there is no turning back. I
have no chance to validate the data and cancel the event when the data isn't
valid. That's not me stealing anything. That's me trying to provide a more
robust application for my users that integrates with the 3rd party site in a
safe way.

Thanks to you, other people will likely not respond to my post in any
relevant and useful way because they may think that I'm trying to steal
something.

-V
 
C

cody

You could put your own button on top of that component's button.
if the user clicks on your button and you have validated your data do a
button.performclick() on the button of that component.
but there is one problem: you have to get a reference to that button first..
maybe you can loop through the ControlsCollection of the component to find
it.
 
V

Verde

Thank you cody.

Your advice is exactly what I eventually figured out how to do last night
after the initial post. It works great! The 3rd party component now never
even appears in the UI and I still get to leverage its useful functionality.
I now validate the data, if it's all cool I then instantiate the 3rd party
component, set various other properties of the component and then fire its
click event. The *validated* data + user gets routed to the 3rd party site.

-V
 
V

Verde

.... and for those interested, in ASP.NET (i.e., WebForms) it's not
button.performclick(), rather it is object.RaisePostBackEvent("click") -
like this:
some3rdPartyComponent.RaisePostBackEvent("click");
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top