Reputation: 2841
On a web form I have an asp:button with the OnClientClick set to some javascript, the script opens a new tab then the code behind the button does a Response.Redirect, leaving the original page open in the original tab.
How can I amend this so that a Response.Redirect also happens on the original tab also? IE new tab opens with booking.aspx as per code below, but original tab CurrentPage.aspx changes to NewPage.aspx?
script:
<script type = "text/javascript">
function SetTarget() {
document.forms[0].target = "_blank";
}
</script>
button code-behind:
protected void btnGo_Click(object sender, EventArgs e)
{
Response.Redirect("booking.aspx?id=" + lbBooking.Text + "&flag=exists");
}
Upvotes: 0
Views: 842
Reputation: 3800
Try this:
function SetTarget() {
document.forms[0].target = "_blank";
window.location.href = 'YourURL';
}
Upvotes: 1