简体   繁体   English

如何在按钮单击时关闭简单的模态对话框?

[英]How to close a simple modal dialog on a button click?

Here i am trying to close a modal dialog on a button click but it is not closing the dialog.Here is my code 在这里,我试图关闭按钮单击模式对话框,但它没有关闭对话框。这是我的代码

function closemodal() {
    alert("true");
    $.modal.close();
    return false;
}

and

protected void btnOK_Click(object sender, EventArgs e)
{
    ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "ScriptRegistration", "closemodal();", true);
}

i need to call a javascript function and after that i need to close that dialog..Any suggestion?? 我需要调用一个javascript函数,之后我需要关闭该对话框。任何建议?

EDIT: 编辑:

  $(document).ready(function () {
        $('#MainContent_uscRetailParameters_btnOK').click(function (e) {
            closemodal();
            return false;
        });
        function closemodal() {
            $.modal.close();
        }
    });

EDIT 2: 编辑2:

  $('#CusCatPOPUP .basic').click(function (e) 
{ 
$('#CusCatPOPUP-content').modal(); 
return false; 
}
); 

Unless I'm missing the point: 除非我错过了这一点:

$('#MainContent_uscRetailParameters_btnOK').click(function (e) {
    MyFunctionCall();   //i.e. call you function here
    $.modal.close();
    return false;
});

Might be an error elsewhere, check your browser console. 可能是其他地方的错误,请检查您的浏览器控制台。

Created an example: http://jsfiddle.net/eTnJF/ 创建了一个例子: http//jsfiddle.net/eTnJF/

With code: 使用代码:

$(document).ready(function() {
    $('.open').click( function() {
        $('#modal').modal();
    });

    $('.close').click( function() {
        closemodal();
        return false;
    });

    function closemodal() {
        alert("true");
        $.modal.close();
    }
});

Which works fine :) 哪个工作正常:)

If you want to simply close the modalpopup then the javascript code is. 如果你想简单地关闭modalpopup,那么javascript代码就是。

var mpu = $find('ModalPopupExtender1');
mpu.hide();

Hope it helps. 希望能帮助到你。

thanks Kamran 谢谢Kamran

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

相关问题 如何通过Selenium和C#根据HTML在模态对话框中单击文本为“关闭”的按钮 - How to click on the button with text as Close within a modal dialog box as per the html through Selenium and C# 如何使用javascript自动单击dhtml模态对话框窗口按钮? - how to auto click dhtml modal dialog window button using javascript? 模式对话框未关闭 - modal dialog not close 模态对话框仅通过单击一个按钮即可加载,而不管类似按钮的数量如何-如何解决? - Modal dialog loads just from the click on one button regardless of the number of similar buttons - how to fix it? Selenium WebDriver - 无法在模态对话框中找到并单击提交按钮 - Selenium WebDriver - Unable to find and click a Submit button on modal dialog ASP.net按钮点击不使用Jquery模态对话框触发 - ASP.net Button on click not firing using Jquery Modal Dialog 按下OK后如何防止模式对话框关闭? - How to prevent modal dialog form to close after pressing OK? 如何在Microsoft PowerPoint / Office应用程序中触发模式对话框关闭? - How to trigger a modal dialog box to close in Microsoft PowerPoint / Office applications? 如何从iframe单击按钮关闭ModalPopupExtender - How to close ModalPopupExtender on a button click from an iframe 如何刷新页面? (单击按钮关闭RadWindow) - How to refresh the page? (Click button close RadWindow)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM