Click here to Skip to main content
15,888,610 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Dear all,


I have a gridview. i want to open a new page in new tab on linkbutton click from gridview in code behind on button_click. because i am fetching the row index and empcode value on this click .how?
Posted

once try this
protected void btn_Click(object sender, EventArgs e)
{
 ScriptManager.RegisterStartupScript(Page, typeof(Page), "OpenWindow", "var test=window.open('MyPage.aspx?Param=1','_blank'); if(test) test.focus()", true);

}


It is working in Crome version 39 and in crome version 38 it is opening in another new window.
it is working in IE10 and IE11.
 
Share this answer
 
v3
Comments
Amit Vasi 4-Oct-14 2:37am    
It open in new window but i want tin same window new Tab.
Try it.

C#
ScriptManager.RegisterStartupScript(Page, GetType(), "Whatever", "window.open('yourPage.aspx?Param=1','_blank')", true);



Thanks
AARIF SHAIKH
 
Share this answer
 
Since you want to open it inside the very window but in new tab, use HTML tag or target for the hyperlinks like this

HTML
<a href="link" target="_blank">Click me</a>


target="_blank" specifies that this page would open in the same window, but in a new window.

Remember, ASP.NET controls transform to HTML strings on the server-side and are sent as HTML strings (elements) to the browser. So, whether it is a GridView (table in HTML) or any other control. Once in the browser you will be using the basic HTML ways of doing stuff, and/or JavaScript to handle them. So, using JavaScript won't be a bad idea either. Stuff run on the code block in Web Forms only, where you've specified the runat="server" attribute to the element.
 
Share this answer
 
why don't you use ajax modalpopupextender then
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900