I have a parent.aspx form with a 'btnOpen' button on it . On 'btnOpen' click, I open a Jquery Dialog box which contains a iframe. The iframe 'src' is a child.aspx form. The child form has 'btnOK' button. When I click 'btnOK' button, I want the dialog on
the parent form to close. To do that (on the child form), on 'btnOK' button click, I do the following code:
$(document).ready(function()
{
$("#btnOK").live('click',
function()
{
window.parent.closeIframe();
});
});
The function CloseIframe() is on the parent aspx page and looks like this:
function
closeIframe() {
$("#dialog2").dialog("close");
returnfalse;
}
All works fine, except when there is asynchronous postback, the UI dialog box is never closed. Any suggestions, as to what I doing wrong here?
where are you doing async postback? in parent form or child form? does the asynch postback removes and element from DOM?
after asynch postback, check in firebug that u have the required controls and script available.... are you getting any javascript error?
Async postback is happening in parent form : I have more controls (dropdownlist, radiobuttonlist) on the parent.aspx form (within the same updatepanel as 'btnOpen' control). These controls causes asynchronous postbacks. When I try opening the dialog again,
it opens fine but would not close.
I havnt tried firebug as yet but no there is no javascript error.
function
closeIframe() {
$("#dialog").dialog("close");
returnfalse;
}
On the child form:
$(document).ready(function()
{
$("#btnOK").live('click',
function()
{
window.parent.closeIframe();
});
});
The dialog is a div [style = display:none] inside a updatepanel on parent page; it works fine until another controls within the updatepanel causes a asynchronous postback.
Note: Actually, its behaves weird. The Jquery dialog overlay disappears but not the actual dialog.
AnjumNagpal
Member
46 Points
60 Posts
Jquery UI Dialog box doesnot close on asynchronous postback
Feb 24, 2012 02:50 PM|LINK
I have a parent.aspx form with a 'btnOpen' button on it . On 'btnOpen' click, I open a Jquery Dialog box which contains a iframe. The iframe 'src' is a child.aspx form. The child form has 'btnOK' button. When I click 'btnOK' button, I want the dialog on the parent form to close. To do that (on the child form), on 'btnOK' button click, I do the following code:
$(document).ready(function() {
$("#btnOK").live('click', function() {
window.parent.closeIframe();
});
});
The function CloseIframe() is on the parent aspx page and looks like this:
function closeIframe() {
$("#dialog2").dialog("close");
return false;
}
All works fine, except when there is asynchronous postback, the UI dialog box is never closed. Any suggestions, as to what I doing wrong here?
kedarrkulkar...
All-Star
35563 Points
5700 Posts
Re: Jquery UI Dialog box doesnot close on asynchronous postback
Feb 24, 2012 03:02 PM|LINK
where are you doing async postback? in parent form or child form? does the asynch postback removes and element from DOM?
after asynch postback, check in firebug that u have the required controls and script available.... are you getting any javascript error?
KK
Please mark as Answer if post helps in resolving your issue
My Site
AnjumNagpal
Member
46 Points
60 Posts
Re: Jquery UI Dialog box doesnot close on asynchronous postback
Feb 24, 2012 03:12 PM|LINK
Async postback is happening in parent form : I have more controls (dropdownlist, radiobuttonlist) on the parent.aspx form (within the same updatepanel as 'btnOpen' control). These controls causes asynchronous postbacks. When I try opening the dialog again, it opens fine but would not close.
I havnt tried firebug as yet but no there is no javascript error.
AnjumNagpal
Member
46 Points
60 Posts
Re: Jquery UI Dialog box doesnot close on asynchronous postback
Feb 24, 2012 03:34 PM|LINK
I checked in Firebug, The closeIframe() script is not longer there. Any suggestion, how to acheive that?
kedarrkulkar...
All-Star
35563 Points
5700 Posts
Re: Jquery UI Dialog box doesnot close on asynchronous postback
Feb 25, 2012 05:59 AM|LINK
u might have placed closeFrame() function inside updatepanel....
instead put this function in head tag of page...
hope this helps...
KK
Please mark as Answer if post helps in resolving your issue
My Site
AnjumNagpal
Member
46 Points
60 Posts
Re: Jquery UI Dialog box doesnot close on asynchronous postback
Feb 27, 2012 02:26 PM|LINK
It is already within the header tag.
kedarrkulkar...
All-Star
35563 Points
5700 Posts
Re: Jquery UI Dialog box doesnot close on asynchronous postback
Feb 27, 2012 02:30 PM|LINK
difficult to guess the issue.... unless you can post the complete code of both the pages
KK
Please mark as Answer if post helps in resolving your issue
My Site
AnjumNagpal
Member
46 Points
60 Posts
Re: Jquery UI Dialog box doesnot close on asynchronous postback
Feb 27, 2012 02:49 PM|LINK
On the Parent Form:
var btn = '<%= btnRefresh.ClientID %>';
$(document).ready(function() {
$("#btnOpenChildWindow").live('click', function() {
$("#dialog").empty().append(
$("<iframe>").attr({ "src": "child.aspx?btn="+ btn,
"width": "100%",
"height": "100%",
"marginwidth": "0",
"marginheight": "0",
"scrolling": "auto",
"frameborder": "0"
}));
$("#dialog").dialog({ modal: true, title: 'Child Window', width: 400, height: 450 });
$("#dialog").parent().appendTo('form');
return false;
});
});
and
function closeIframe() {
$("#dialog").dialog("close");
return false;
}
On the child form:
$(document).ready(function() {
$("#btnOK").live('click', function() {
window.parent.closeIframe();
});
});
The dialog is a div [style = display:none] inside a updatepanel on parent page; it works fine until another controls within the updatepanel causes a asynchronous postback.
Note: Actually, its behaves weird. The Jquery dialog overlay disappears but not the actual dialog.
kedarrkulkar...
All-Star
35563 Points
5700 Posts
Re: Jquery UI Dialog box doesnot close on asynchronous postback
Feb 27, 2012 03:01 PM|LINK
try moving the dialog div outside updatepanel.... since, it is dealt with in jQuery only, it should not be issue...
hope this helps...
KK
Please mark as Answer if post helps in resolving your issue
My Site
AnjumNagpal
Member
46 Points
60 Posts
Re: Jquery UI Dialog box doesnot close on asynchronous postback
Feb 27, 2012 03:26 PM|LINK
It worked.. thanks.