closing browser window from server code

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.
 
H

Hans Kesting

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
 
D

DM

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.
 
D

DM

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?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,011
Latest member
AjaUqq1950

Latest Threads

Top