Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Popup Window doesn't work with smartNavigation enabled?

Posted on 2004-04-28
15
Medium Priority
?
1,526 Views
Last Modified: 2012-06-21
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
Comment
Question by:Dean_Hastings
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
15 Comments
 
LVL 28

Expert Comment

by:mmarinov
ID: 10937201
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
 

Author Comment

by:Dean_Hastings
ID: 10937961
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
 
LVL 28

Accepted Solution

by:
mmarinov earned 1000 total points
ID: 10938031
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
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.

 

Author Comment

by:Dean_Hastings
ID: 10938474
Tried your suggestion. Focus is still falling on the parent window?
0
 
LVL 28

Expert Comment

by:mmarinov
ID: 10938515
i've tried this  on my computer and it works fine!
0
 

Author Comment

by:Dean_Hastings
ID: 10939022
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
 
LVL 28

Expert Comment

by:mmarinov
ID: 10939073
no, i don't use smartNavigation!
B..M
0
 

Author Comment

by:Dean_Hastings
ID: 10939218
This is the problem I have, as I am using smartNavigation.
0
 
LVL 28

Expert Comment

by:mmarinov
ID: 10939403
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
 

Author Comment

by:Dean_Hastings
ID: 10939606
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
 
LVL 28

Expert Comment

by:mmarinov
ID: 10939676
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
 

Author Comment

by:Dean_Hastings
ID: 10939873
Focus still on Parent window after moving client script into aspx page!
0
 
LVL 28

Expert Comment

by:mmarinov
ID: 10940067
sorry Dean, i'm out of ideas :(
B..M
0
 

Expert Comment

by:apollo18
ID: 11780331
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
 
LVL 6

Expert Comment

by:JohnDesautels
ID: 13670640
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

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article discusses the ASP.NET AJAX ModalPopupExtender control. In this article we will show how to use the ModalPopupExtender control, how to display/show/call the ASP.NET AJAX ModalPopupExtender control from javascript, how to show/display/cal…
A quick way to get a menu to work on our website, is using the Menu control and assign it to a web.sitemap using SiteMapDataSource. Example of web.sitemap file: (CODE) Sample code to add to the page menu: (CODE) Running the application, we wi…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Suggested Courses

670 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question