创建从ASP.NET网页一个新的标签或窗口 [英] Create a new tab or window for a web page from ASP.NET

查看:176
本文介绍了创建从ASP.NET网页一个新的标签或窗口的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有我想成为一个排序调度中心对我的web应用程序的用户的主页。所以,我想主要页面停留开放的,但当用户选择某些任务,我可以将它设置这样一个新的标签或页面与他们所选的任务创建。

I have a main page that I want to be a sort of dispatch center for the user in my web application. So I want the main page the stay open, but when the user selects certain tasks I can set it up so that a new tab or page is created with the task that they selected.

我知道如何控制转移到另一个页面,但我怎么可以这样做一个Server.Transfer的唯一做出新的页面出现在新的标签,并保持现有的网页在旧标签/窗口打开?

I know how to transfer control to another page, but how can I do something like a Server.Transfer only make that new page appear in a new tab and keep the existing page open in the old tab/window?

要给予我在做什么的例子。目前,我有我的主要页面上的中继器构造LinkBut​​tons的列表。该LinkBut​​tons有从数据源中的文本。一旦上的链接按钮,用户点击,我要翻开新的一页,我想会话状态为preserved这一新的一页。

To give an example of what I'm doing. I currently have a repeater on my main page which constructs a list of LinkButtons. The LinkButtons have text from the data source. Once the user clicks on a link button, I want to open a new page and I want Session state to be preserved with this new page.

可以这样做,以及如何?

Can this be done, and how?

我在.NET 3.5使用ASP.NET版本。

I'm using the version of ASP.NET in .NET 3.5.

编辑:我不在乎是否其选项卡或窗口。我只是希望能够产卵一个新的网页,并保持现有的开放。

I don't care whether its a tab or window. I just want to be able to spawn a new web page and keep the existing one open.

推荐答案

您不能更改用户界面行为服务器端(例如,通过使用Server.Transfer的或Response.Redirect的) - 它只是不工作的方式。因此,有两种方法可以去一下:

You can't change UI behavior server-side (for example, by using Server.Transfer or Response.Redirect) - it just doesn't work that way. So, there are two ways you can go about this:


  1. 如果你提前知道时间,这具体任务需要打开一个新窗口/选项卡中,适当地设置锚点或窗体标记的目标(或使用JavaScript的window.open()函数)。

  2. 如果打开一个新窗口/标签的决策需要进行服务器端,可以生成并返回的javascript,做你所需要的。

请记住,新的标签/窗口行为是完全依赖于浏览器和用户的设置,所以没有办法保证,这将发生 - 某些设置甚至可以强制在同一个窗口中打开的所有链接,无论目标或调用window.open()

Keep in mind that new tab/window behavior is completely dependent on the browser and the user's settings, so there's no way to guarantee which will happen - some settings can even force all links to be opened in the same window, regardless of the target or calling window.open().

如果您使用的是基于cookie的会话,这是默认的功能,即使在新窗口或标签,用户依然会使用同一个会话,所以你不应该做什么特别的preserve会话状态。

If you are using a cookie-based session, which is the default functionality, even in a new window or tab, the user will still be using the same session, so you shouldn't have to do anything special to preserve the session state.

如果您使用的是基于URL(或无cookie)会话密钥,你需要确保你使用JavaScript打开新窗口时适当使用密钥格式的URL。我还不能肯定,但我相信这只是使用target属性和相对url应自动生成相应的URL。

If you are using a url-based (or cookieless) session key, you will need to make sure you format the url appropriately using the key when opening new windows with javascript. I'm not positive, but I believe simply that using the target attribute and relative urls should automatically generate the appropriate url.

这篇关于创建从ASP.NET网页一个新的标签或窗口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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