views:

192

answers:

3

I have a web app with a start page composed of various links. I used the LinkButton control of System.Web.UI.WebControls for these links. I do a little bit of processing on postback, then I redirect to the appropriate page. The problem I find is that in IE7 I cannot right click the "link" and open in a new tab. The postback occurs and the new page appears, but in the current tab, not a new one! I tried the web app in chrome as well, and chrome doesn't even give the option when right clicking the link.

It appears that if the destination page might need to be opened in a new tab by the user, I need to use a hyperlink or the hyperlink control. However, it would be nice if I still had the option to do some processing before jumping to that link.

+1  A: 

You could use a HyperLink to some intermediate page and pass some querystring parameters. And then do your redirect in the pageload of the intermediate page. That way you could still open up the links in a new tab or window.

Nick
+4  A: 

Typically it is bad practice to use a LinkButton like a normal hyper link, and even a worse idea to do a 302 redirect after the POST back has occurred.

  1. For one thing it breaks the browser interaction which you have already found.
  2. But more importantly it breaks search engine indexing of your site, if you have an external site.

Also you still can do some pre-processing on an actual hyperlink, but you just do it in a different manor. If you tell us what you are doing maybe we can help find a better way.

Nick Berardi
App has a button that says new XXX. Before the site can jump to the new XXX page, the site needs to call a web service to return a new identifier for XXX
Brian Vander Plaats
You can also do this. If the page is entered with out the new identifier for XXX you can call the web service and get it.
Nick Berardi
+1  A: 

Why not just pass querystrings with the data you need? Posting back, then redirecting not only kills performance (2x as many round trips for the client), but it reeks of bad design.

Daniel Schaffer