如何在Main主页面中触发click事件 [英] How to fire the click event in Main masterpage

查看:131
本文介绍了如何在Main主页面中触发click事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,



如何触发其嵌套主页子页面按钮点击事件的Mainmasterpage中的点击事件。



请告诉我任何一个。



thanku

hi all,

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

please tell me any one.

thanku

推荐答案

你不能开火 (调用)任何地方的任何事件,除了声明事件的类型,甚至在派生类中。这是一个重要的限制(与常规委托实例相比),这使事件变得如此安全和有价值。如果单击事件,当用户实际点击物理鼠标时将触发该事件。如果可以模拟,但在较低级别,通过原始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 [ ^ ]。 我认为你不想要它。



事情是:我确定你不要实际上需要来开火和事件。您只需要具有与调用事件时相同的效果。这将是一个不同的故事,更合理的事情。执行以下操作:



仅向所需单击事件的调用列表添加一个处理程序。在此处理程序中,调用一些单独的函数;这应该是事件处理程序中唯一的语句。并在其他地方写一个对此函数的调用,在那里你要模拟点击。就这么简单。



-SA
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


这篇关于如何在Main主页面中触发click事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆