Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem with pages .aspx #9

Open
Luengas opened this issue Feb 20, 2015 · 3 comments
Open

Problem with pages .aspx #9

Luengas opened this issue Feb 20, 2015 · 3 comments

Comments

@Luengas
Copy link

Luengas commented Feb 20, 2015

Hi, in a .apsx page doesn't return OK data to the parent page. Displays the 'window alert' before closing modal window. In .HTML pages works perfectly.

$(".abrirModal2").click(function() {

    var ruta = "demoModal.aspx";

    var sFeatures = "dialogHeight: 600px; dialogWidth: 900px;";
    var o = window.showModalDialog(ruta, "", sFeatures);

   alert(o);


});
@niutech
Copy link
Owner

niutech commented Feb 24, 2015

Could you provide a URL so that I could investigate it?

@pshyani
Copy link

pshyani commented Nov 17, 2016

I have the similar problem...
I like your alternative for ShowModalDialog. I have one problem using it in Asp.net Project.

  1. When ModalPopUp opens, it does not stop execution of button click event.
    Here is my code:

    <asp:LinkButton runat="server" ID="LnkCust" Text="Select Cust" OnClick ="LnkCust_Click" />

JavaScript code for this button:

  $('#' + '<%= LnkCust.ClientID %>').click(function (e) {
     var RetObject =  window.showModalDialog('Customer.aspx',  "",'dialogHeight:600Px;dialogWidth:1200Px;');
            alert(RetObject);
            if (RetObject == null) {
                return false;
            }
            else {
                strCustomerUniqIDList = new String(RetObject.strCustomerUniqIDList);
                strCustomerUniqNoList = new String(RetObject.strCustomerUniqNoList);
                if (strCustomerUniqIDList.length > 0) {
                    if (strCustomerUniqIDList.length > 0){
                        $('#' + '<%= TxtSelectCustomerList.ClientID %>').value = strCustomerUniqIDList;                
                    return true;
                }
                else
                    return false;
            }
}

.net code for button click:

protected void LnkCust_Click(object sender, System.EventArgs e)
{
.........
........
}

My problem is when modal dialog is open, It also executes above button click event.
It should execute after modal dialog gets close.

When modal dialog is closed, nothing gets executed, not even rest of JavaScript code which is written after showModalDialog.

Please help.

@mrwoodo
Copy link

mrwoodo commented Sep 2, 2021

A bit late, but in case others hit this problem. You need to :
a) use async/await pattern
b) call event.preventDefault() to stop the form postback,
c) manually postback if necessary, once the popup has closed (the __doPostBack line in the example below)

async function ShowPopUp() {
    var caller = event.target;
    event.preventDefault();
    var strOutPut = await window.showModalDialog('mypage.aspx', null, '');
    if (typeof (strOutPut) != "undefined") {
        if ((strOutPut != "") && (strOutPut == "Yes")) {
            __doPostBack(caller.id.replaceAll('_', '$'), "");
        }
    }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants