0
votes

I have written a code to open a page as modal popup. it works fine. but when the page is opened as a dialog and i click the asp button of the opened page it causes page to go spawn in a window..and parent page goes away... how can i fix the problem so that if i do postback in popped page then also it should remain as popup in main page.

when i click on the button in Payment_Delivery_Scheduling.aspx it causes page to redirect on that page in browser.

function openPaymentAndDeliveryModel(id) {
            var windowWidth = $(window).width() / 1.25;
            var windowHeight = $(window).height() /1.5;
            $('#popup').load("Payment_Delivery_Scheduling.aspx?id=" + id + "", function () {

            });
            $('#popup').dialog({ modal: true, height: windowHeight, width: windowWidth });
        }
1
I think you have to deal this one by ajax call on Popup button clicked and do the things. - Neeraj Dubey
How to do that ? can you give some details for that.... - Sachin Trivedi

1 Answers

0
votes

Hey Sachin Sample code is

 $("#btnSubmit").live("click", function (e) {
    if ($('#txtPwd').val().length < 1) {
        $('#lblResponse').text('Please enter password to move ahead.').addClass("fail-message"); ;
        $('#txtPwd').focus();
    } else {
        callAjax($('#txtPwd').val());
        e.preventDefault();
    }
});

function callAjax(hashVal) {
var address = "Home.aspx";
$.ajax({
    type: 'POST',
    url: address,
    data: { pwd: hashVal },
    beforeSend: function () {
        // this is where we append a loading image
        $('#ajax-panel').html('<div class="loading"><img src="images/loading.gif" alt="Loading..." /></div>');
    },
    success: function (data) {
        // successful request; do something with the data
        $('#ajax-panel').empty();
        var actualData = data.trim().split('~');

        $("#lblResponse").html(actualData[0]);
        $('#txtPwd').val('');
        if (actualData[1] == "true") {
           window.location.href = window.referer = $('#lnkMyCorner').attr('href');
        }

    },
    error: function () {
        // failed request; give feedback to user
        $('#ajax-panel').html('<p class="error"><strong>Oops!</strong> Try that again in a few moments.</p>');
    }
});
}

Hope It Helps you