I'm using a web grid and I am using TargetUrl to assign a link.
his.webGrid.Rows[i].Cells.FromKey("Name").TargetURL = "Item.aspx?id=" + Id;
But this link is opening a new page on the same page but I wanted to open a new window for this page. Could you please help me?
Updated
I found this code in this forum and it is working fine but it is opening the explorer but unfocused. It opens the window and keep the current window focused. Am I making any mistakes?
{
e.Row.Cells[0].Value = href;
}
function PODetailsGrid_CellClickHandler(gridName, cellId, button){ var currentCell = igtbl_getCellById(cellId); convChartWindow = window.open("conversioncharts/" + currentCell.getValue() + ".html", "chart", "location=0,0, status=1, scrollbars=1, width=" + screen.width + ", height=175"); self.setTimeout('setWindowFocus(convChartWindow)', 1000) } function setWindowFocus(w) { w.focus(); }
Hello,
Yes, I believe this is the expected behaviour. In the first case, the link is opened in the same page in the second case, target = "_blank" instructs the link to open in a new window. Still, in order to focus to another browser window, you would need javascript and window.open command (e.g. execute command with BLOCKED SCRIPTwindow.open(href, size)) so it's a bit more complicated than that.
In that case you would have a javascript onclick event for the image and in a custom javascript function you would open a new window with window.open and then set focus to it. One possible technique is described here:
http://www.webdeveloper.com/forum/showthread.php?t=141095