Home All Groups Group Topic Archive Search About
Author
29 Dec 2005 4:03 PM
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

Author
29 Dec 2005 4:32 PM
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?
Author
29 Dec 2005 5:03 PM
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
Author
29 Dec 2005 5:17 PM
Zamdrist
Most excellent...now if I could just figure out what the 'key' value
really represents so that it actually runs it...

addup wrote:
Show quoteHide quote
> 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
Author
29 Dec 2005 5:36 PM
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>
Author
29 Dec 2005 5:58 PM
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();")
Author
29 Dec 2005 8:03 PM
Zamdrist
That works perfect!

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

Thank you very much addup!