NAORC
asked on
How can I close the current aspx web form?
Hi,
I've an asp.net web app in C#, and I want to have a button which will close the form, thus exiting the application. Equivalent to the user clicking the X button.
In the button click event I've tried: btn_CloseForm.Attributes.A dd("onclic k","window .close('Fo rmName.asp x');");
...however, nothing happens the first time this is clicked, and the second time its clicked a messagebox appears asking for confirmation that the user wants to close the form. I need the form to close immediately on clicking the 'closeForm' button.
Thankyou.
I've an asp.net web app in C#, and I want to have a button which will close the form, thus exiting the application. Equivalent to the user clicking the X button.
In the button click event I've tried: btn_CloseForm.Attributes.A
...however, nothing happens the first time this is clicked, and the second time its clicked a messagebox appears asking for confirmation that the user wants to close the form. I need the form to close immediately on clicking the 'closeForm' button.
Thankyou.
ASKER
Cheers, this doees close the window without a warning, but only once the button has been clicked twice. The first click causes a page reload, and the second click closes the page.
Is there a way to do this in one click?
Cheers.
Is there a way to do this in one click?
Cheers.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
BTW, a browser window opened by you can not be closed, without a browser warning. There are unsupported workarounds like setting a window.opener a value and then closing it.
Try this:
btnCloseForm.Attributes.Ad
(But this unsupported workaround may not be supported by future web browsers).