Click here to Skip to main content
15,880,651 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
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
Updated 28-Sep-12 0:09am
v3

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[^]
 
Share this answer
 
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.

XML
<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.

C#
$(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
 
Share this answer
 

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900