如何在新标签页中打开页面 [英] How to open page in new tab

查看:134
本文介绍了如何在新标签页中打开页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

亲爱的,





我有一个gridview。我想在linkbutton上的新选项卡中打开一个新页面,点击button_click后面代码中的gridview。因为我在这个点击上获取行索引和empcode值.how?

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?

推荐答案

一旦尝试这个

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);

}





它在Crome版本39和crome版本38中工作,它在另一个新的开放窗口。

它在IE10和IE11中工作。



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.


试试吧。



Try it.

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







谢谢

AARIF SHAIKH




Thanks
AARIF SHAIKH


由于你想在窗口内但在新标签页面中打开它,请使用HTML标签或 target 对于这样的超链接



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

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





target =_ blank指定此页面将在同一窗口中打开,但是在一个新窗口中。



请记住,ASP.NET控件在服务器端转换为HTML字符串,并作为HTML字符串(元素)发送到浏览器。因此,无论是GridView(HTML表格)还是任何其他控件。一旦进入浏览器,您将使用基本的HTML方式来处理它们和/或JavaScript。因此,使用JavaScript也不是一个坏主意。 Stuff仅在Web窗体中的代码块上运行,您已在该元素中指定 runat =server属性。



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.


这篇关于如何在新标签页中打开页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆