Link to home
Start Free TrialLog in
Avatar of PrimeNY
PrimeNY

asked on

Calling a Java PopUp window from VB.Net code

Creating a web site using Visual Web Developer 2005 Express (Asp.Net 2.0) using VB.
I have a page that uses Java PopUp windows:

<SCRIPT LANGUAGE="JavaScript">
function popUp(URL) {
day = new Date();
id = day.getTime();
eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=500,height=200,left = 390,top = 284');");}

And then calll the popup with:

<a href="javascript:popUp('../popup.htm')">
 <span style="font-size: 16pt"><strong>?</strong></span></a>

Now I would like to call a popup for the same page within VB code:

Protected Sub NewButton_Click(ByVal sender As Object, ByVal e As System.EventArgs)
        If CheckBox3.Checked = False And CheckBox4.Checked = False Then
            'call popup
        End If

Can I do this?

Thanks in advance for your help.
Avatar of samtran0331
samtran0331
Flag of United States of America image

Protected Sub NewButton_Click(ByVal sender As Object, ByVal e As System.EventArgs)
        If CheckBox3.Checked = False And CheckBox4.Checked = False Then
            If Not Page.ClientScript.IsStartupScriptRegistered("MyScript") Then
               Page.ClientScript.RegisterStartupScript(Me.GetType, "MyScript", "<script type=""text/javascript"">popUp('../popup.htm');</script>")
            End If
        End If
Avatar of PrimeNY
PrimeNY

ASKER

Thanks, and I'm sure this is a stupid question but....how do I keep the popup window on top.  It shows for a second and then hides behind main page.
>>I'm sure this is a stupid question but

Not at all!
With javascript "window.open"....you can't always force it to stay on top....you can try modifying your script so that it does try to keep the popup modal....but you might still get inconsistent results with different browsers....
http://javascript.about.com/library/blmodal.htm

A different route is to use something like:
http://www.asp.net/AJAX/AjaxControlToolkit/Samples/ModalPopup/ModalPopup.aspx
Avatar of PrimeNY

ASKER

The problem is that as soon as a user clicks on the buttom in the main page that opens the popup window, the popup window flashes on top for just a split second and then the popup window is immediately minimized.  I understand that it is difficult to keep the popup window on top when users click elsewhere, but that is not my concern.  I just need the popup to stay on top when it is initially opened.  

I think (as you indicated) that I need "window.open" in the VB code that you provided, but I don't know where.  Sorry, but my limited background is only in Flash and VB5.
ASKER CERTIFIED SOLUTION
Avatar of samtran0331
samtran0331
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of PrimeNY

ASKER

After hours of investigative work through my code I discovered that the problem was caused by me putting "SmartNavigation="True" in the page directive to return the page when RequiredFieldValidator is triggered.

Thanks very much for your help!