OnClientClick [英] OnClientClick

查看:56
本文介绍了OnClientClick的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我有一个用来创建按钮控件的用户控件.它不是从按钮继承的.该控件由3个按钮组成.我需要在客户端单击此控件时运行脚本,以运行一些javascript.此按钮"控件具有在运行时通过委托生成的clicked事件.是否可以向此用户控件或一般任何其他用户控件添加OnClientClick事件?

感谢您的帮助.

Hi,

I have a user control that I used to create a button control with. It doesn''t inherit from button. This control is composed of 3 buttons.I need to run a script on client click of this control to run some javascript. This "button" control has a clicked event generated during runtime through delegates. Is it possible to add an OnClientClick event to this user control or any other user control in general?

Thanks for your help

推荐答案

OnClientClick仅处理javascript click事件,如果返回false,则不进行回发.如果您的控件不是从提供此控件的控件派生的,那么您可以肯定会处理click事件,如果您的控件在客户端获得一个事件,并且我相信可以设置一个布尔值来停止回发,您就可以了"我将需要遍历ASP.NET生成的代码以找到解决方案,或者使用Google来解决.
The OnClientClick just handles the javascript click event, and if it returns false, does not do a postback. If your control is not derived from a control that offers this, you can certainly handle a click event, if your control gets one on the client side, and I believe there''s a boolean you can set that will stop postback, you''ll need to trawl through the code generated by ASP.NET to work out a solution, or google for it.


我建​​议您在其中公开一个新属性,例如"OnClientClickCustom"您的用户控制.在其中进行获取/设置,您可以在其中处理将为此属性设置的值.

在设置分配的值的同时,您可以将OnClientClick属性附加到各个按钮.另外,任何其他使用控件属性的Javascript事件.
这应该做!
I would suggest you to expose a new property like ''OnClientClickCustom'' in yor user control. Have a get/set in it where you can handle the value you will set for this property.

Whil setting the value assigned, you can attach OnClientClick property to individual buttons. Also, any other Javascript event using controls Attribute.
This should do!


这篇关于OnClientClick的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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