Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1530
  • Last Modified:

Popup Window doesn't work with smartNavigation enabled?

I am using the following Sub to open a popup browser window when btnOpen is clicked.

    Private Sub btnOpen_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnOpen.Click
        Response.Write("<script>window.open('ClientSidePopupChild.aspx',null,'width=400,height=300');</script>")
    End Sub

This works fine when smartNavigation for the page is disabled. Once smartNavigation is enabled a client side error "invalid pointer" is produced.
Does anyone now what I am doing wrong? Any help is appreciated.

Dean


0
Dean_Hastings
Asked:
Dean_Hastings
1 Solution
 
mmarinovCommented:
use this
    Private Sub btnOpen_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnOpen.Click
        Response.Write("<script>window.open('ClientSidePopupChild.aspx',null,'width=400,height=300');</script>")
        Dim scriptString as String = "<script language=JavaScript>"
        scriptString += "window.open('ClientSidePopupChild.aspx',null,'width=400,height=300');</script>"
     
            If(Not IsClientScriptBlockRegistered("clientScript"))
              RegisterClientScriptBlock("clientScript", scriptString)
           End If

    End Sub

B..M
0
 
Dean_HastingsAuthor Commented:
This works (with Response.write line removed) except that the popup window is tucked behind the parent window. The focus needs to be on the popup window?

Dean.
0
 
mmarinovCommented:
of course it will be on the parent window not on pop
you have to set it
something like this

 scriptString += "var w = window.open('ClientSidePopupChild.aspx',null,'width=400,height=300');w.focus();</script>"



B..M
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
Dean_HastingsAuthor Commented:
Tried your suggestion. Focus is still falling on the parent window?
0
 
mmarinovCommented:
i've tried this  on my computer and it works fine!
0
 
Dean_HastingsAuthor Commented:
Was smartNavigation enabled on your PC?

On my PC, with smartNavigation disabled the focus is on the child page. With smartNavigation enabled the focus is on the parent.

    Private Sub btnOpen_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnOpen.Click
        Dim scriptString As String = "<script language=JavaScript>"
        scriptString += "var w = window.open('ClientSidePopupChild.aspx',null,'width=400,height=300');w.focus();</script>"

        If (Not IsClientScriptBlockRegistered("clientScript")) Then
            RegisterClientScriptBlock("clientScript", scriptString)
        End If
    End Sub

By the way, thanks for your help on this!!
0
 
mmarinovCommented:
no, i don't use smartNavigation!
B..M
0
 
Dean_HastingsAuthor Commented:
This is the problem I have, as I am using smartNavigation.
0
 
mmarinovCommented:
try this
in page_load

btnOpen.Attributes.Add("onclick", "<scrip language=javascript>var w = window.open('ClientSidePopupChild.aspx',null,'width=400,height=300');w.focus();</script>")

and remove the client script from the onclick server event

By the way, please excuse me that i've not read your question carefully

B..M
0
 
Dean_HastingsAuthor Commented:
Got a syntax error when including the <script> tag.

Using the following provided a popup window but the focus was still on the parent.

    Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        btnOpen.Attributes.Add("onclick", "var w = window.open('ClientSidePopupChild.aspx',null,'width=400,height=300');w.focus();")
    End Sub

Maybe smartNavigation gives more pain than gain??
0
 
mmarinovCommented:
try to wrte a client script in your aspx page
<script language="javascript">
 function showMe()
 {
  var w = window.open('ClientSidePopupChild.aspx',null,'width=400,height=300');
  w.focus();
 }
</script>

and modify this
 btnOpen.Attributes.Add("onclick", "var w = window.open('ClientSidePopupChild.aspx',null,'width=400,height=300');w.focus();")

to
 btnOpen.Attributes.Add("onclick", "showMe()")


HTH
B..M
0
 
Dean_HastingsAuthor Commented:
Focus still on Parent window after moving client script into aspx page!
0
 
mmarinovCommented:
sorry Dean, i'm out of ideas :(
B..M
0
 
apollo18Commented:
SmartNavigation doesn't interfere with the focus if you use an html control instead of a server control to open a popup window:

<script>
function OpenWindow()
{
window.open('ClientSidePopupChild.aspx',null,'width=400,height=300');
}
</script>

<a href="javascript:OpenWindow">Click here to open window</a>
0
 
JohnDesautelsCommented:
Here is a solution for returning the focus to the child even with SmartNavigation enabled.

http://www.experts-exchange.com/Programming/Programming_Languages/Dot_Net/ASP_DOT_NET/Q_20988044.html

John
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now