Try this.
This code open window fromclient side and redirect by new url in same open window, if any exception occures then close window after 4 sec.
code:
Protected Sub EditSchematic_click(ByVal sender As Object, ByVal e As EventArgs) Handles EditSchematic.Click
Try
Dim URL As String = "Google.com"
ScriptManager.RegisterStartupScript(Me, Me.GetType, "myUniqueKey", "OpenWebWindow('" & URL & "'," & ConfigurationManager.AppSettings("WindowWidth") & "," & ConfigurationManager.AppSettings("WindowHeight") & ");", True)
Catch ex As Exception
ScriptManager.RegisterStartupScript(Me, Me.GetType, "myUniqueKey", "CloseWindow()", True)
End Try
End Sub
aspx code:
<asp:Button CssClass="btn" runat="server" ID="EditSchematic" OnClientClick="openblankwindow();" />
<script>
function openblankwindow() {
width = screen.width;
height = 0.87 * screen.height;
var st = "toolbar=0,location=0,directories=0,status=1,menubar=0,scrollbars=1,resizable=0,left=" + 0 + ",top=" + 0 + ",width=" + width + ",height=" + height;
win = window.open("Processing.htm",
}
function CloseWindow() {
width = screen.width;
height = 0.87 * screen.height;
var st = "toolbar=0,location=0,directories=0,status=1,menubar=0,scrollbars=1,resizable=0,left=" + 0 + ",top=" + 0 + ",width=" + width + ",height=" + height;
win = window.open("errorMsgInOpenning.htm",
setTimeout(function () {
win.close()
}, 4000);
}
function OpenWebWindow(URL, width, height) {
// screen.availWidth, screen.availHeight
var left = 0;
var top = 0;
if (width <= 0) {
width = screen.width;
}
else {
left = (screen.width / 2) - (width / 2);
}
if (height <= 0) {
height = 0.87 * screen.height;
}
else {
top = (screen.height / 2) - (height / 2);
}
var st = "toolbar=0,location=0,directories=0,status=1,menubar=0,scrollbars=1,resizable=0,left=" + left + ",top=" + top + ",width=" + width + ",height=" + height;
window.open(URL,
}
</script>