I am new to asp.net and currently using Visual Studio 2012.
Currently, I am working on a login page where I have two buttons: Login
and Exit
.
Whenever I click on the Exit
button, I want the application to close and also stop the debugging process.
I came across a solution on this link where various approaches are discussed, but I prefer the following method:
protected void Page_Load(object sender, EventArgs e)
{
ClientScript.RegisterOnSubmitStatement(typeof(Page), "closePage", "window.onunload = CloseWindow();");
}
Furthermore, I wrote the following javascript function within the Login.aspx file:
<script language="javascript" type="text/javascript>"
function CloseWindow() {
window.close();
}
</script>
Note: While the above script successfully closes the application when I click on the Exit button, it also closes the application when I click on the Login
button, and debugging does not stop as intended.