When my Login button is clicked, if the login was successful I’d like to close the browser.
protected void btnLogin_Click(object sender, AuthenticateEventArgs e)
{
if (isAuthenticated)
{
// close the browser
}
}
I’m not using AJAX so this happens on code behind.
How to send a command (or a javascript call) to the browser to close itself using C# and perhaps using Response… object?
thanks,
UPDATE on the Answer (it closes without warning):
const string scriptKey = "closeBrowser";
if (!ClientScript.IsClientScriptBlockRegistered(scriptKey))
{
ClientScript.RegisterClientScriptBlock(this.GetType(), scriptKey, "javascript:setTimeout('parent.Shadowbox.close();', 1000);", true);
}
The following can be ran server side to add
window.close()javascript method to your client script. However, the results of this will depend on your browser.