How to Open a Centered Child Window:
Here is some code you can add to a module (or Shared class) and then call in
your UI (PageLoad w/o postback) like this.
This creates the java script and assigns it to a control with a Click event
(like a button).
If you want mouseover events setStatus=True and pass in a statusComment.
=================================================================
In Page_Load try something like this:
If Not IsPostBack Then
YourClassName.AssignCentered(Button1, "Login.aspx", "YourFormName", 500,
400, False, False, False, False, True, True, "Open Login page as centered
popup")
End If
==================================================================
Public Shared Sub AssignCentered(ByVal ctl As WebControl, ByVal pagePath
As String, ByVal windowName As String, ByVal width As Integer, ByVal height
As Integer, ByVal hasToolbar As Boolean, ByVal hasMenubar As Boolean, ByVal
hasStatus As Boolean, ByVal hasScrollbars As Boolean, ByVal isResizable As
Boolean, ByVal setStatus As Boolean, ByVal statusComment As String)
Dim clientScript As String
Dim statusScript As String
Dim windowAttribs As String
windowAttribs = "toolbar=" & Bool2Int(hasToolbar) & _
",menubar=" & Bool2Int(hasMenubar) & _
",status=" & Bool2Int(hasStatus) & _
",scrollbars=" & Bool2Int(hasScrollbars) & _
",resizable=" & Bool2Int(isResizable) & _
",width=" & width & "px" & _
",height=" & height & "px" & _
",left='+((screen.width -" & width & ")/2)+'" & _
",top='+ (screen.height - " & height & ")/2+'"
'Build the client script - window.open, with additional parameters
clientScript = "window.open('" & pagePath & "','" & windowName & "','" &
windowAttribs & "');return false;"
'window.open('About.aspx','MyAboutBox','toolbar=0,menubar=0,status=0,scrollb
ars=1,resizable=1,width='+lnWidth+',height='+lnHeight+',top='+lnTop+',left='
+lnLeft+'');return false;"
statusScript = "window.status='" & statusComment & "';"
'register the script to the clientside events of ctl
ctl.Attributes.Add("onClick", clientScript)
If setStatus = True Then
ctl.Attributes.Add("OnMouseOver", statusScript)
ctl.Attributes.Add("OnMouseOut", "window.status='';")
End If
End Sub
Private Shared Function Bool2Int(ByVal Value As Boolean) As Integer
If Value = True Then
Return 1
Else
Return 0
End If
End Function