Wrox Programmer Forums
|
ASP.NET 1.0 and 1.1 Basics ASP.NET discussion for users new to coding in ASP.NET 1.0 or 1.1. NOT for the older "classic" ASP 3 or the newer ASP.NET 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.0 and 1.1 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old September 29th, 2007, 10:39 AM
Authorized User
 
Join Date: Jun 2006
Posts: 38
Thanks: 0
Thanked 0 Times in 0 Posts
Default close window with out message box

I have an visual studio web aspx application with a close window command button, named finish on my aspx application web page. I have code below that closes the page when clicked, but, I stoll receive the warning message. How can I get the aspx page to simply close "with out the message box requiring a yes or no" to close.

Here is my existing code:

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
           FinishButton1.Attributes.Add("onclick", "window.opener = top; window.close();")
    End Sub

    Protected Sub FinishButton1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles FinishButton1.Click
                Response.Write("<script language='javascript'> { self.opener = top; self.close() }</script>")

    End Sub
 
Old September 29th, 2007, 11:40 AM
Wrox Author
 
Join Date: Oct 2005
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default

You can't close the parent window without IE spawning that message, it is a security feature that you can not override.

================================================== =========
Read this if you want to know how to get a correct reply for your question:
http://www.catb.org/~esr/faqs/smart-questions.html
================================================== =========
Technical Editor for:
Professional Search Engine Optimization with ASP.NET
Professional IIS 7 and ASP.NET Integrated Programming
Wrox Blox: Introduction to Google Gears
Wrox Blox: Create Amazing Custom User Interfaces with WPF and .NET 3.0
================================================== =========
 
Old September 29th, 2007, 01:12 PM
Authorized User
 
Join Date: Jun 2006
Posts: 38
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thank you,

I asked the question because, I saw a previous post about the same thing I am working on, http://p2p.wrox.com/topic.asp?TOPIC_ID=37337, and decided to give it a try.

 
Old September 29th, 2007, 01:23 PM
Authorized User
 
Join Date: Jun 2006
Posts: 38
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hello,

I just want to close the current window that I am using. When I clik on a link on on my main menu, a new window page opens. I would like to close the new window without a message.

THank you in advance.

 
Old September 29th, 2007, 02:51 PM
Wrox Author
 
Join Date: Oct 2005
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default

How do you open the new window? Normally if you use the javascript function: window.open() to open a new window, that window can be closed with window.close() without receiving the warning message.

================================================== =========
Read this if you want to know how to get a correct reply for your question:
http://www.catb.org/~esr/faqs/smart-questions.html
================================================== =========
Technical Editor for:
Professional Search Engine Optimization with ASP.NET
Professional IIS 7 and ASP.NET Integrated Programming
Wrox Blox: Introduction to Google Gears
Wrox Blox: Create Amazing Custom User Interfaces with WPF and .NET 3.0
================================================== =========
 
Old September 29th, 2007, 03:08 PM
Authorized User
 
Join Date: Jun 2006
Posts: 38
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I open the new window from an hyperlink (version 2.0.0.0 .net) using the NavigateUrl property set to the page and the Target property set to _blank.

Thank you in advance,

 
Old September 29th, 2007, 03:42 PM
Wrox Author
 
Join Date: Oct 2005
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default

Ok, just a general FYI, this is not related in anyway to the .NET framework, it is more how IE handles how windows are closed.

What you should try, instead of using a normal hyperlink, is to use the window.open() function to open your window and then try calling the close window function. This should work for you. (You could trigger the window.open event from a hyperlink however.)

hth.

================================================== =========
Read this if you want to know how to get a correct reply for your question:
http://www.catb.org/~esr/faqs/smart-questions.html
================================================== =========
Technical Editor for:
Professional Search Engine Optimization with ASP.NET
Professional IIS 7 and ASP.NET Integrated Programming
Wrox Blox: Introduction to Google Gears
Wrox Blox: Create Amazing Custom User Interfaces with WPF and .NET 3.0
================================================== =========
 
Old September 29th, 2007, 05:17 PM
Authorized User
 
Join Date: Jun 2006
Posts: 38
Thanks: 0
Thanked 0 Times in 0 Posts
Default

The command button with the window.open code attached works when I use the command directly on a form, but when I use it from within a InsertItemTemplate it does not work.

 
Old September 29th, 2007, 07:01 PM
Wrox Author
 
Join Date: Oct 2005
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default

What do you mean?

================================================== =========
Read this if you want to know how to get a correct reply for your question:
http://www.catb.org/~esr/faqs/smart-questions.html
================================================== =========
Technical Editor for:
Professional Search Engine Optimization with ASP.NET
Professional IIS 7 and ASP.NET Integrated Programming
Wrox Blox: Introduction to Google Gears
Wrox Blox: Create Amazing Custom User Interfaces with WPF and .NET 3.0
================================================== =========
 
Old October 1st, 2007, 05:30 AM
Friend of Wrox
 
Join Date: Aug 2004
Posts: 550
Thanks: 0
Thanked 1 Time in 1 Post
Default

Well you can try this, this should close the page without message

window.opener = null; window.close();


Regards
Mike





Similar Threads
Thread Thread Starter Forum Replies Last Post
close window with out message box nutrino ASP.NET 1.0 and 1.1 Basics 2 December 6th, 2005 04:26 PM
window.close() failing to...well...close! mheathcote Javascript How-To 2 October 31st, 2005 03:02 PM
Programmatically close a message box 12th_Man VB How-To 3 June 25th, 2004 05:44 PM
Close Parent window on opening child window pkdev Javascript How-To 8 April 11th, 2004 12:06 PM
How do i close pop-up window?: window.close () Burton HTML Code Clinic 2 September 8th, 2003 05:40 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.