Adds

Tuesday, 4 March 2014

Open a .aspx page on a new tab in asp.net button click event using javascript

Code For .aspx page:

<asp:Button ID="btnAbout" runat="server" Text="About" onclick="btnAbout_Click" OnClientClick="return PostToNewWindow();"/>


Java Script Function:

<script type="text/javascript">
    function PostToNewWindow() {
        originalTarget = document.forms[0].target;
        document.forms[0].target = '_blank';
        window.setTimeout("document.forms[0].target=originalTarget;", 300);
        return true;
    }
</script>


Code in .cs Page For Button Click:

protected void btnAbout_Click(object sender, EventArgs e)
{
Response.Redirect("~/About.aspx");
}

That's It.