简体   繁体   English

OnClick事件调用js函数和回调函数

[英]OnClick event calling a js function and a callback function

I have an external compiled project(asp.net) that we are using in our code. 我有一个外部编译项目(asp.net),我们在我们的代码中使用。 I dont have access to the code behind, just the .aspx pages. 我无法访问后面的代码,只有.aspx页面。

One of the things Im trying to do is to call two functions from the button in the page. 我尝试做的一件事就是从页面中的按钮调用两个函数。

<cc1:ImageButton ID="btnYes" runat="server" OnClick="btnYes_Click" Text="Yes"
                        Width="40px" SkinID="DefaultButton" />

Is there a way I can add a JS function and let the OnClick event call both btnYes_Click and my JS function? 有没有办法可以添加JS函数,让OnClick事件同时调用btnYes_Click和我的JS函数? something like this? 这样的事情? OnClick="btnYes_Click ; myfunction();"

I dont have any access to the code behind page. 我没有任何访问页面后面的代码。

Yes there is an event called OnClientClick="JSFunction" add that to your control. 是的,有一个名为OnClientClick =“JSFunction”的事件将其添加到您的控件中。 if not then add it from codebehind like MyControl.Attributes["onclick"] = "JSFunction"; 如果没有,那么从代码隐藏中添加它,如MyControl.Attributes [“onclick”] =“JSFunction”;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM