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
1825
Keeping focus on a new browser window?
posted
Evening all,
Hope someone can tell me what it is I am doing wrong with the below code.
Its suppose to, on clicking the btn in the grids cell, popup a new browser window and keep it on top of the calling browser.

VB.net codebehind, on a ASP.net page.

Protected Sub uwGridResults_ClickCellButton(ByVal sender As Object, ByVal e
As Infragistics.WebUI.UltraWebGrid.CellEventArgs) Handles
uwGridResults.ClickCellButton

Try
Dim strTheLink As String = ""
strTheLink = "file:" & e.Cell.Row.Cells.FromKey("LinkToFollow").Text
strTheLink = strTheLink.Replace("\", "/")

Dim strLink As String = "<script> var myW = window.open('" & strTheLink
& "', 'myW'); myW.focus(); </script> " ' '_self' parent.resizeTo(480,600);

ClientScript.RegisterStartupScript(Me.GetType(), "ClientScript", strLink)

Catch ex As Exception

End Try


End Sub

What it does is call up the document in the new browser and then bring the calling browser to the front, hiding the popup document.

What am I doing wrong?

Thanks
Deasun
Parents
No Data
Reply
  • 45049
    posted

    Without having tested this code, I suspect that you're seeing a race condition.

    Many NetAdvantage for ASP.NET controls use RegisterStartupScript() to initialize their client-side objects.  The trouble with this is that a programmer can't control the order in which multiple scripts logged with RegisterStartupScript() are run.  In this case, it's likely that the scripts for the NetAdvantage for ASP.NET controls are happening after your window opens, and thus steals focus back to the parent window.

    I can think of a couple options to get around this, and there are likely others:

    1. Use a different approach to register the script that opens your other window.  One possible place is to handle the "onload" event of the BODY element.  Another is to handle an "Initialize" client-side event on a NetAdvantage for ASP.NET control, such as the InitializeLayout event of WebGrid.
    2. Use window.setTimeout() to delay the opening of the child window.  The amount of delay you'll need will vary depending on the ability of the client machine to process data quickly, so this may not be an easily-scalable option.

    Please remember that these forums area a peer-to-peer resource to share issues and ideas with other Infragistics users.  If you require official support from Infragistics for further assistance, please submit a support incident to Infragistics Developer Support from this page of our website.

Children