繁体   English   中英

分配javascript事件处理程序时触发Asp .Net Linkbutton事件

[英]Asp .Net Linkbutton event firing when javascript event handler is assigned

我在asp .net aspx页面中有一个linkbuton。 我在另一个页面中使用jquery ui对话框打开该页面。

从打开页面的代码中,我在新打开的页面中的按钮上放置了一个事件处理程序来关闭页面。

我的问题是,即使没有点击按钮,事件也会触发。 我的窗口出现一秒钟然后消失。

这是我的代码:

            if (hdnShowVote.val() == "True" && vote == null) {
            $("#divModal1").dialog({ height: 500, width: 800, modal: true, hide: "fade", closeOnEscape: true, closeText: "", title: "Vote", dialogClass: 'modalBare' })
            $("#ifrVote").attr("src", "CustomerVote.aspx");
            $("#ifrVote").ready(function () {
                $("#ifrVote").contents().find("#btnClose_CustomerVote").click(closeVote());
                alert($("#ifrVote").contents().find("body").length);
            });
        }

任何想法为什么会这样?

这是因为你设置你的函数在页面的document.ready上执行,称为$("#ifrVote")

暂无
暂无

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

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