简体   繁体   English

使用NavigateUrl,如何在浏览器中打开一个新窗口而不是一个选项卡?

[英]Using NavigateUrl, how to open a new window instead of a tab in the browser?

I've got a page that presents a bunch of part numbers to my users. 我有一个页面,向用户展示了一堆零件号。 I want a new window to open when the user clicks on a part number. 我希望在用户单击零件号时打开一个新窗口。 The MSDN page for NavigateURL seems to indicate that I just put Target="_blank" in the properties for the Hyperlink, but that just pops a new tab (in Chrome if it matters). NavigateURLMSDN页面似乎表明我只是在超链接的属性中放置了Target="_blank" ,但这只是弹出一个新标签页(如果重要的话,在Chrome中)。

How do I get it to pop a new window instead of a new tab? 如何使其弹出一个新窗口而不是一个新选项卡? I tried to delete the DataNavigateUrlFormatString property because it seemed extraneous, but it didn't like that and told me that "Target was not a valid option for a hyperlink" , or something to that effect (if it's important I can get the exact error). 我试图删除DataNavigateUrlFormatString属性,因为它看起来似乎无关紧要,但它不喜欢该属性,并告诉我"Target was not a valid option for a hyperlink" ,或者有类似效果(如果很重要,我可以得到确切的错误) )。

Here's my code: 这是我的代码:

<asp:HyperLinkField HeaderText="Part Number"
DataTextField="partNumber"
DataNavigateUrlFields="partNumber"
DataNavigateUrlFormatString="PartLookup.aspx?partNumber={0}"
NavigateUrl="PartLookup.aspx?partNumber={0}"
Target="_blank"/>

The browser being used decides how to handle being given a target="_blank" , and you can not control whether it chooses to make a new tab or window. 使用的浏览器决定如何处理给定的target="_blank" ,并且您无法控制它是否选择制作新的标签页或窗口。

You can use Javascript to force the opening of a new window, but I do not believe that can be done through your HyperLinkField directly. 您可以使用Javascript强制打开一个新窗口,但是我不认为可以直接通过HyperLinkField来完成。

See this issue for Javascript 看到这个问题的JavaScript

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM