Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Progammatically setting "Target" for hyperlink columns in gridview?

Status
Not open for further replies.

DatabaseDude

Programmer
Nov 7, 2005
112
0
0
US
A gridview contains a list of links, a menu of sorts, for users in an app. Some are external, some are internal. (Aside from the external beginning with " they are also flagged in the database with an IsUrl field.)

We'd like the external links to open in a new window (target = blank). However, the target argument doesn't seem to like having code inside of it. Is there a way to write this?

Thanks in advance!
 
in the aspx where your url is specified, you could try something like:

"javascript:window.open('yourURL');
 
Use the rowdatabound event of the gridview to check the value. If it's an external link, get a reference to the link an then add the "target" attribute to it.
 
It's a Decision Made From Above that the links to external sites should open in new windows.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top