Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
695
Opening a new window using TargetUrl
posted

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?

protected void runsdetailWebGrid_InitializeRow(object sender, RowEventArgs e)

{

string pathStr = "file:" + e.Row.Cells.FromKey("Path").Value.ToString();string href = String.Format("<a href='{0}' target='_blank'> <img src='Images/folderstep2.GIF' style='border-style: none' /></a>", pathStr);

e.Row.Cells[0].Value = href;

}

 

  • 640
    posted
    You can open the second window and keep the focus on the second window if you use the Window.setTimeout() method. For example, I want to launch a second window (who's name is based upon the value of the current cell) over the primary window when a cell is clicked.
    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();
    }
    
  • 14049
    Offline posted
    You also could simply prefix your URL with @. It is described in the API
    docs:
    http://help.infragistics.com/Help/NetAdvantage/NET/2008.3/CLR3.5/html/Infragistics35.WebUI.UltraWebGrid.v8.3~Infragistics.WebUI.UltraWebGrid.UltraGridCell~TargetURL.html
  • 28464
    posted

    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