I want to open a page in new tab of browser on button click.
I have searched a lot on google but i couldn't find anything.
Here is my button.
<asp:Button ID="btnNewEntry" runat="Server" CssClass="button" Text="New Entry" OnClick="btnNewEntry_Click" /> protected void btnNewEntry_Click(object sender, EventArgs e) { Response.Redirect("New.aspx"); }
Can you please help me how i can do this ?
open allows you to open a page in new window or tab. Here's a client-side example: $(function () { $('#<%= YourButtonID. ClientID %>').
You just need to use the '_blank' without 'left=100,top=100,resizable=yes' if you want it to open in new tab.
Default key bindings: F2 create a tab. F3 & F4 you can move around back and forth.
You could use window.open
. Like this:
protected void btnNewEntry_Click(object sender, EventArgs e) { Page.ClientScript.RegisterStartupScript( this.GetType(),"OpenWindow","window.open('YourURL','_newtab');",true); }
Why not just call window.open straight from OnClick?
<asp:Button ID="btnNewEntry" runat="Server" CssClass="button" Text="New Entry" OnClick="window.open('New.aspx')" />
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With