Window.Close Opens New Annoying Window

  • Thread starter Thread starter Vijay Kerji
  • Start date Start date
V

Vijay Kerji

Hi,
Please go through the following scenario.
1)On Button click, Parent window opens a child window using
showModalDialog
2)Button is a server control and showModalDialog script is registered
using the following code:

string scriptblock = "<script language='javascript'>returnValue =
window.showModalDialog('Datagrid1.aspx', 'xxx');" +
"if(returnValue == 0) window.open('Webform1.aspx', '_self'); else
window.open('Datagrid1.aspx', '_self'); </script>";
Page.RegisterStartupScript("Launch_Report_Window",scriptblock);

3)In the Child window there is a SAVE server button control and the
following
code is added in PageLoad for the button:
Button_Save.Attributes.Add("onclick","javascript:window.returnValue
= 0;window.close();");

4)When OnSave button is clicked, a new child window is getting opened
though the modal window is closed, which is annoying.

Any intelligent guess/suggestoins are appreciated.

Thanks


Vijay K Kerji
 
Any intelligent guess/suggestoins are appreciated.

Postback of a modalDialog will post back to a new window unless you
encapsulate the entire code in an <iframe> tag.
 
Vijay,

Try putting a line

<base target=_self>

in the <Head> section of the page shown in the modal window.

Eliyahu
 
Back
Top