showModalDialog
showModalDialog copied to clipboard
Problem with pages .aspx
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);
});
Could you provide a URL so that I could investigate it?
I have the similar problem... I like your alternative for ShowModalDialog. I have one problem using it in Asp.net Project.
-
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.
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('_', '$'), "");
}
}
}