Closing window/page

Z

Zamdrist

Use code-behind form, visual basic, running some code behind a command
button, all good...the last step though should be that the use is
prompted with a message, and then the window or page should
close...can't figure out how to do this otherwise simple task.

I imagine DHTML could do it, but I should be able to access the browser
window's methods from VB.Net also, right?

I tried the obvious...Page.Close...well there is no Close method, and
Dispose isn't right...

Could someone point me in the right drection? Thanks!

Steve
 
Z

Zamdrist

Ok...figured that part out...must you client side code in order to use
the Close method of the Window object.

Well, that leaves me in a bind...the button still first needs to run
code, VB.Net code...and close the window...can I do both?
 
A

addup

use page.registerstartupscript
and run window.close from there

note that many browsers will show an alert if you use this to close a
window that has been explicitly opened by the user
 
Z

Zamdrist

Most excellent...now if I could just figure out what the 'key' value
really represents so that it actually runs it...
 
Z

Zamdrist

Unfortuantely the example provided my MS here:

ms-help://MS.VSCC.2003/MS.MSDNQTR.2003FEB.1033/cpref/html/frlrfSystemWebUIPageClassRegisterStartupScriptTopic.htm

1. Shows the example not using code-behind VB, but client side only
2. The Key value appears by thier example so arbitrary value assiged by
the coder by random. Would make sense if the id value of the script
block matched the key value argument of RegisterStartupScript but that
doesn't appear to be the case (I tried).

<sigh>
 
A

addup

LOL

I just use a generic function in my (common) base class

Public Sub RunScript(ByVal Page As System.Web.UI.Page, ByVal Script As
String)
Static iSeq As Integer = 0
Page.RegisterStartupScript("Script" & iSeq, "<SCRIPT
language='javascript'>" & Script & "</SCRIPT>")
iSeq += 1
End Sub


that I can invoke simply by

RunScript("window.close();")
 
Z

Zamdrist

That works perfect!

Well after I added the Page argument to RunScript...call :)

Thank you very much addup!
 

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

Forum statistics

Threads
473,754
Messages
2,569,528
Members
45,000
Latest member
MurrayKeync

Latest Threads

Top