Open new page

Below code works fine. However, how can I display it right in the center of the screen?

Dim fullURL As String = "window.open('" & "myurl") & "', '_blank', 'height=700,width=900,status=no,toolbar=no,menubar=no,location=no,scrollbars=yes,resizable=no,titlebar=no' );"
        ScriptManager.RegisterStartupScript(Me, GetType(String), "OPEN_WINDOW", fullURL, True)
VBdotnet2005Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Kyle AbrahamsSenior .Net DeveloperCommented:
Copy and paste the code found here:
http://www.mindfiresolutions.com/Opening-a-popup-window-at-center-of-the-screen-819.php

fullURL would become just the function call with the appropriate parameters.
0
VBdotnet2005Author Commented:
What am I doing wrong?
public Sub ViewPage()

 Dim fullURL As String = popup("http://www.google.com", "test", 500, 800)  
ScriptManager.RegisterStartupScript(Me, GetType(String), "OPEN_WINDOW", fullURL, True)


    End Sub

    Public Function popup(ByVal pageURL As String, ByVal title As String, ByVal popupWidth As String, ByVal popupHeight As String) As String

        Dim left = "(screen.width / 2) - (popupWidth / 2)"
        Dim top = "(screen.height / 2) - (popupHeight / 2)"
        Dim targetPop As String
        targetPop = "window.open(pageURL, title, 'toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=YES, resizable=YES, copyhistory=no, width=' +" & popupWidth & "+ ', height=' + " & popupHeight & "+ ', top=' + " & top & "+ ', left=' + " & left & ");"
        Return targetPop

    End Function
0
Kyle AbrahamsSenior .Net DeveloperCommented:
This goes in your front end as javascript:

<script type="text\javascript">
function popup(pageURL, title, popupWidth, popupHeight)
    {
        var left = (screen.width / 2) - (popupWidth / 2);
        var top = (screen.height / 2) - (popupHeight / 2);
        var targetPop = window.open(pageURL, title, 'toolbar=no, location=no, directories=no,
status=no, menubar=no, scrollbars=YES, resizable=YES, copyhistory=no, width=' + popupWidth + ',
height=' + popupHeight + ', top=' + top + ', left=' + left);
    }
</script>


this would go in your code behind:

 Dim fullURL As String = "popup('http://www.google.com', 'test', 500, 800) "
ScriptManager.RegisterStartupScript(Me, GetType(String), "OPEN_WINDOW", fullURL, True)
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
ASP.NET

From novice to tech pro — start learning today.