Click here to Skip to main content
15,916,951 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I am opening a window's Form from and webpage, Now when i close browser tab, or browser, window form remain alive.
How can i close that window form on closing browset or tab ?
pradiprenushe 25-Nov-13 13:31pm    
How are you opening window form?
footballpardeep 25-Nov-13 13:41pm    
Form f=new Form();;
pradiprenushe 25-Nov-13 13:50pm    
Why you sre using windows form in web? Any particular reason.
ZurdoDev 25-Nov-13 14:41pm    
This won't work in the web. C# code executes on the server generating HTML which is sent to the client.
footballpardeep 25-Nov-13 14:00pm    
I have developed a customized confirm box. whoes yes/no result we can take on server.

1 solution

It is a bad practice to mix Windows Forms and ASP.Net. They don't work alike and nowdays there are ways to program Web Pages to make them behave almost entirely or even better than a Windows Form (HTML5, jQuery, AJAX, or even with plugins sucha as JavaFX, Flash and Silverlight).

A confirmation can be fetched with a simple javascript "confirm". It works like a Yes/No MessageBox:

<asp:button id="btnConfirm" runat="server" onclientclick="return confirm('Confirm action?');" onclick="btnConfirm_Click" />

The button configuration above will first throw a confirm box, and catch the response on c# or VB for the method btnConfirm_Click which you need to have in advance.

Your current aproach will display erratic behavior such as what you're getting, and will be incompatible with all non-Windows devices (Apple, Android, etc.).
Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900