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.
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?
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?
I’m using the version of ASP.NET in .NET 3.5.
Edit: 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.
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:
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().
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.
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.