2

Hi it is very simple question, but I didn't find the answer fit in my situation.

In my jQuery dialog I have buttons which is update and close. User click 'update button' then on code behind I need to update in database then close. when user click the close button then I close the dialog. the dialog is load aspx page. I have two problems.

  1. The problem is if user click close button which run javascript window.close(). It will pop up the windows "Do you want to close window...."

  2. How can I refresh the parent page and close the dialog by clicking the 'update' button.

there is the code to load the dialog:

function openDialog(url, name, width, height) {

$("#dialog-box").load(url).dialog({       
    autoOpen: false,
    resizable: true,
    height: 425,
    width: 600,
    modal: true         
});

$('#dialog-box').dialog('open');

return false;



}

I tried to use $("#dialog-box").dialog("close"); in my function which is called in code behind. but it show the error.

there is my function

function RefreshParentAndClose() {

$("#dialog-box").dialog("close");
}

enter image description here

there is the code I load the dialog on parent page

<div id="dialog-box" title=" "></div>
<td width="33%" align="right"><asp:button id="btnSelect" runat="server" causesvalidation="False" text="Select Locations"
                    OnClientClick="javascript:return openDialog('popLocation.aspx','select',600,500);"    /></td>
user819774
  • 1,456
  • 1
  • 19
  • 48

2 Answers2

0

1) You could close the dialog by invoking its close() method:

function OnCloseClick() {
    $("#dialog-box").dialog("close");
}

2) You just need to refresh the main page. On the subsequent load the dialog should not be opened (in case you do not load it automatically). More information about the method's parameter used below could be read from this answer on StackOverflow.

function OnUpdateClick() {
    window.opener.location.reload(false);
}
Community
  • 1
  • 1
0

Use below code for close

 $("#dialog-box").dialog( "close" ); 

and to refrsh on close use

 $("#dialog-box").dialog({
 close: function( event, ui ) {
  window.location.reload();
 }
 });
Nishith Kant Chaturvedi
  • 4,719
  • 2
  • 16
  • 24