Click here to Skip to main content
16,021,041 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
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.

thanku
Posted

1 solution

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, http://msdn.microsoft.com/en-us/library/windows/desktop/ms646310%28v=vs.85%29.aspx[^], http://www.pinvoke.net/default.aspx/user32.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.

—SA
 
Share this answer
 
v2

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900