SpaceApple
SpaceApple

Reputation: 1327

Open new tab from asp button's codebehind

Basically I have a inside a grid and when the user clicks on this button I want it to open a new tab on the same browser. I have tried everything and I feel like pulling my hair out on this.

Any ideas on how to approach this?

Upvotes: 1

Views: 7542

Answers (4)

Gopal Sharma
Gopal Sharma

Reputation: 1

Please Try This code. It works Perfectly..

Response.Write("window.open('YourPageName.aspx','_blank');");

Upvotes: 0

Jayesh Amin
Jayesh Amin

Reputation: 324

Try using ScriptManager.RegisterStartupScript(Page, typeof(Page), "newwindow", "window.open('MyPage.aspx?querystring=" + parameter.ToString() + "');",true);

Upvotes: 1

alexo
alexo

Reputation: 934

You can style a link as a button in css.

The html code could look like this :

<a href="" target="_blank">Open</a>

Explanation:

target="_blank" - this will tell the browser to open your link in a new tab.

Upvotes: 0

Roy Dictus
Roy Dictus

Reputation: 33149

Generate the following HTML code for your button:

<button onclick="window.open('http://www.url.com')">Open</button>

Whether that will open a new tab or a new window depends on the user's browser settings -- this is not something you can control.

Upvotes: 0

Related Questions