Groups | Blog | Home
all groups > asp.net > june 2003 >

asp.net : Close window with JavaScript


jhe_bc NO[at]SPAM yahoo.ca
6/28/2003 12:52:27 PM
Hello

I have some trouble in closing a window, Here is the problem:

I develop a asp.net website use client side valiation

<asp:CustomValidator id="CustomValidator1"
ControlToValidate="Text1"
ClientValidationFunction="BasicSearchValidation"
OnServerValidate="ServerValidation"
Display="Static"
ErrorMessage="Not an even number!"
ForeColor="green"
Font-Name="verdana"
Font-Size="10pt"
runat="server"/>


the validation function (JavaScript) is

BasicSearchValidation(source, arguments)
{
...

w1 = window.open("PopupErrorMsg.htm", "example1", "width=400,
height=300, location=no, menubar=no, status=no, toolbar=no,
scrollbars=no, resizable=no");
...
}

ASP.net will automatically call BasicSearchValidation and open a
window,
but when I click close button on the window, it always prompt a
messagebox to ask me to close it. How can I close the window without
the prompting the messagebox?

Thanks!


Vidar Petursson
6/28/2003 8:10:36 PM
Hi

If your app did not open the window ( window.open ) you will get a confirm
box
http://msdn.microsoft.com/library/default.asp?url=/workshop/author/dhtml/reference/methods/close_0.asp

There is a hack but I don't think its a good idea using it so I wont post it
:)

--
Best Regards
Vidar Petursson
==============================
Microsoft Internet Client & Controls MVP
==============================
[quoted text, click to view]

Kevin Spencer
6/30/2003 8:25:47 AM
window.opener = self;
window.close();

HTH,

Kevin Spencer
Microsoft FrontPage MVP
Internet Developer
http://www.takempis.com
Big things are made up of
lots of Little things.

[quoted text, click to view]

AddThis Social Bookmark Button