Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: Javascript HTML jQuery
Hi,
 
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: http://projectshadowlight.org/jquery-easy-confirm-dialog[^] 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!
 
Thanks
Posted 1-Aug-12 0:17am
Edited 28-Sep-12 0:09am
v3
Rate this: bad
good
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.
Refer:
How to Create a jQuery Confirm Dialog Replacement[^]
ASP.NET jQuery UI confirm dialog [^]
ASP.NET JQuery Confirm Dialog[^]
 
OR
 
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[^]
  Permalink  
Rate this: bad
good
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.
 
Step:1
Add the JQuery UI files into your include directory
 
Step:2
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.
 
GetPopUp();
 
Step:3
Create file YesNo.js by pasting the below code in a text file.
 
$(function() {
 
        var divTag = document.createElement("div");
        divTag.id = "dialog-form";
        divTag.title="Test Pop-Up";
        document.body.appendChild(divTag);
 
        var p = document.createElement("p");
        p.id="msg";
        p.innerHTML=<Your custom message>;
        document.getElementById("dialog-form").appendChild(p);
 
        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 ) {
                    option="True";
                    $( this ).dialog( "close" );
                    //your callback method. what you want to do in case user selects "Yes"
                }
            },
            "No": function() {
                option="False";
                $( 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.
 
Thanks
  Permalink  

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



Advertise | Privacy | Mobile
Web02 | 2.8.140926.1 | Last Updated 28 Sep 2012
Copyright © CodeProject, 1999-2014
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