的OnClick不能正常工作时,我同时使用的onclick&放大器;的OnClientClick [英] OnClick not working when i use both Onclick & OnClientClick

查看:113
本文介绍了的OnClick不能正常工作时,我同时使用的onclick&放大器;的OnClientClick的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有了这个code,我尝试关闭一个窗口(我做了它的工作方式),但我也有被忽略onclick事件!

 <脚本类型=文/ JavaScript的>
            功能GetRadWindow(){
                VAR oWindow = NULL;
                如果(window.radWindow)oWindow = window.radWindow;
                否则,如果(window.frameElement.radWindow)oWindow = window.frameElement.radWindow;
                返回oWindow;
            }            功能CloseDialog(){
                GetRadWindow()close()方法。            }

ASPX页面:

 < ASP:按钮的ID =Button1的=服务器文本=Soumettre CE票
                的onclick =的button1_Click的OnClientClick =CloseDialog();返回false;/>

我的应用程序将不会进入button1_Click事件,任何人都可以帮我找出原因?
在此先感谢

编辑:HTML生成按钮

 <输入类型=提交ID =Button1的的onclick =CloseDialog();值=Soumettre CE票NAME =Button1的/>


解决方案

这篇文章一种解释该问题。你需要,如果你想在服务器事件来触发你的JS返回true。否则,您必须返回false。

和,它也像你将不得不添加UseSubmitBehavior =虚假的基础上:<一href=\"http://stackoverflow.com/questions/2155048/onclientclick-and-onclick-is-not-working-at-the-same-time\">OnclientClick onClick为不同时工作吗?

这看你生成的HTML不仅具有CloseDialog(),而不是调用的button1_Click后尤为明显。这一变化将连接到您的onclick的结尾。

 &LT; ASP:按钮的ID =Button1的=服务器文本=Soumettre CE票
            的onclick =的button1_Click的OnClientClick =CloseDialog();
            UseSubmitBehavior =FALSE/&GT;

With this code, i try to Close a Window (the way i'm doing it works) but i have also an Onclick event which is ignored!

<script type="text/javascript">


            function GetRadWindow() {
                var oWindow = null;
                if (window.radWindow) oWindow = window.radWindow;
                else if (window.frameElement.radWindow) oWindow = window.frameElement.radWindow;
                return oWindow;
            }

            function CloseDialog() {
                GetRadWindow().close();

            }  

ASPX page:

 <asp:Button ID="Button1" runat="server" Text="Soumettre ce ticket" 
                onclick="Button1_Click"  OnClientClick="CloseDialog();return false;"/>

My application never enters Button1_click event, can anyone help me to find out why ? thanks in advance

EDIT: HTML GENERATED FOR THE BUTTON

<input type="submit" id="Button1" onclick="CloseDialog();" value="Soumettre ce ticket" name="Button1"/>

解决方案

This article kind of explains the problem. You need to return true in your JS if you want the server event to trigger. Otherwise, you have to return false.

And, it also looks like you will have to add the UseSubmitBehavior = false based on: OnclientClick and OnClick is not working at the same time?

This is especially evident after seeing that your generated HTML only has the CloseDialog() and not the call to Button1_Click. This change will concatenate to the end of your onclick.

<asp:Button ID="Button1" runat="server" Text="Soumettre ce ticket" 
            onclick="Button1_Click"  OnClientClick="CloseDialog();"  
            UseSubmitBehavior="false"/>

这篇关于的OnClick不能正常工作时,我同时使用的onclick&放大器;的OnClientClick的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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