closing browser window from server code

  • Thread starter Thread starter DM
  • Start date Start date
D

DM

Is there any way, using a server control, to execute a routine (say, add
record to database) and then close the browser window. I'm having a
difficult time doing this using a master\detail model where dialog apsx page
is opened when datagrid item on master page is clicked. Would like to be
able to have detail open in the html dialog where user can edit record, then
click save button to save changes to database, call opener routine to
refresh master data grid, and close the page.

This seems like it must be a pretty common data managment scenario, so I
would assume that there would be a simple means of achieving this.

Have tried using RegisterclientScriptBlock to write a window.close within
the page that is opened as a dialog , but it won't close the window.
 
DM said:
Is there any way, using a server control, to execute a routine (say, add
record to database) and then close the browser window. I'm having a
difficult time doing this using a master\detail model where dialog apsx page
is opened when datagrid item on master page is clicked. Would like to be
able to have detail open in the html dialog where user can edit record, then
click save button to save changes to database, call opener routine to
refresh master data grid, and close the page.

This seems like it must be a pretty common data managment scenario, so I
would assume that there would be a simple means of achieving this.

Have tried using RegisterclientScriptBlock to write a window.close within
the page that is opened as a dialog , but it won't close the window.

Any error messages?
How are you writing this script? You need <script> tags around it!
There is also a "RegisterStartupScript" that you might use for this.

Hans Kesting
 
After database udpate routine I call the following function:

Private Sub ReloadParent()

Dim strScript As String = "<script language='javascript'>" & vbCrLf

strScript += " window.close();" & vbCrLf

strScript += "</script>" & vbCrLf

RegisterClientScriptBlock("CloseScript", strScript)

End Sub

I'm not getting any error messages, it just doesn't do anything.
 
It seems as though the window is closing, but is being re-opened when the
dialog attempts to call the opener's routine to refresh the master data grid
because the opener's startup script used to open the dialog when a datagrid
item is selected is being run again. Is there any way to unregister a
script block?
 
Back
Top