Click here to Skip to main content
13,097,225 members (65,265 online)
Rate this:
Please Sign up or sign in to vote.
See more:
hi all,

How to fire the click event in Mainmasterpage of its nestedmasterpage child page button click event.

please tell me any one.

Posted 3-Dec-12 4:33am

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

You cannot "fire" (invoke) any event anywhere, except the type where the event is declared, not even in a derived class. This is important limitation (compared to "regular" delegate instances), which makes events so safe and valuable. In case of the Click event, it will be fired when a user actually clicks with a physical mouse. If could be simulated, but on a low level, via raw Windows API SendInput,[^],[^]. I don't think you want it.

The thing is: I'm sure you don't actually need to "fire" and event. You just need to have the same effect as you would have when the event is invoked. This would be a different story, much more reasonable thing. Do the following:

Add only one handler to the invocation list of the required Click event. In this handler, call some separate function; this should be the only statement in your event handler. And write a call to this function elsewhere, where you wanted to simulate the click. As simple as that.


This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy |
Web01 | 2.8.170813.1 | Last Updated 3 Dec 2012
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100