Click here to Skip to main content
12,507,674 members (55,949 online)
Rate this:
 
Please Sign up or sign in to vote.
See more: C# ASP.NET
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 3-Dec-12 4:33am

1 solution

Rate this: bad
 
good
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, 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
  Permalink  
v2

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 | Mobile
Web02 | 2.8.160927.1 | Last Updated 3 Dec 2012
Copyright © CodeProject, 1999-2016
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