Click here to Skip to main content
12,688,944 members (30,878 online)
Rate this:
Please Sign up or sign in to vote.
See more: Javascript HTML jQuery

I need a simple custom Yes/No pop up dialog which can halt the execution on parent page till the response is back from this popup.

showModalDialog() does not help me in this case as my browser is Safari (I can use safari only).

solution given on link:[^] could not help me as in my case pop up opened based on some if-else in a user defined function, not directly on any event of a control.

I would appreciate any quick help on this!

Posted 1-Aug-12 1:17am
Updated 28-Sep-12 1:09am
Rate this: bad
Please Sign up or sign in to vote.

Solution 1

You can try jQuery modal-dialog or UI-confirm-dialog and configure it for yes-no option.
How to Create a jQuery Confirm Dialog Replacement[^]
ASP.NET jQuery UI confirm dialog [^]
ASP.NET JQuery Confirm Dialog[^]


you can use Ajax ModalPopupExtender for it if it's an ASP.NET web application.
Refer: ASP.NET confirmation box with yes/no button options using modalpopup[^]
Rate this: bad
Please Sign up or sign in to vote.

Solution 2

Thanks Sandeep, you have shown me a way to find the workaround for my issue.

Folks, I have created a workaround for my modal dialog issue. However, it is not the exact alternative to ShowModalDialog() but can be used as a good workaround.

Add the JQuery UI files into your include directory

Add following code to include JQuery UI files into your parent page from where you want to open the modal dialog.

<link rel="stylesheet" href="jquery-ui-1.8.21/themes/base/jquery.ui.all.css">
<script src="jquery-ui-1.8.21/jquery-1.7.2.js"></script>
<script src="jquery-ui-1.8.21/ui/jquery.ui.core.js"></script>
<script src="jquery-ui-1.8.21/ui/jquery.ui.widget.js"></script>
<script src="jquery-ui-1.8.21/ui/jquery.ui.button.js"></script>
<script src="jquery-ui-1.8.21/ui/jquery.ui.position.js"></script>
<script src="jquery-ui-1.8.21/ui/jquery.ui.dialog.js"></script>
<script language="JavaScript" type="text/javascript" src="_include/YesNo.js"></script>

//on click event on parent page or any function from where you want to open popup
//page, add following code.


Create file YesNo.js by pasting the below code in a text file.

$(function() {

        var divTag = document.createElement("div"); = "dialog-form";
        divTag.title="Test Pop-Up";

        var p = document.createElement("p");"msg";
        p.innerHTML=<Your custom message>;

        var option;

    $( "#dialog:ui-dialog" ).dialog( "destroy" );

    $( "#dialog-form" ).dialog({
        autoOpen: false,
        height: 300,
        width: 350,
        modal: true,
        buttons: {
            "Yes": function() {
                var bValid = true;

                if ( bValid ) {
                    $( this ).dialog( "close" );
                    //your callback method. what you want to do in case user selects "Yes"
            "No": function() {
                $( this ).dialog( "close" );
                    //your callback method. what you want to do in case user selects "No"
        close: function() {

function GetPopUp()
    $( "#dialog-form" ).dialog( "open" );

I hope, it helps for other coders who are facing this issue.


This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web02 | 2.8.170113.4 | Last Updated 28 Sep 2012
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100