How to send a pop up window from .vb file.

  • Thread starter Thread starter Lily
  • Start date Start date
L

Lily

Hi there, please help on why this is happening:
I have tried to the following on my button click event, nothing is happening, no pop up new window. I could not think of anything wrong here.
'********
Private Sub btnCalculate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCalculate.Click

If CheckBalance() = 1 Then

Dim str As String = "<script language=""javascript"">" & _

" function openpopup(){ " & _

"winpops = window.open(""co2.aspx"", """", ""alwaysRaised,width=400,height=338,"")" & _

"} " & _

" openpopup();" & _

"</script>"

Response.Write(str)

End If

End Sub

'********
 
Lily,

It's because nothing is calling the function when it's placed on the page.

Instead using response.write to place the script on the page try using
Page.RegisterStartUpScript instead.

If you'd like, I've created a Javascript component that can be placed on any
page and contains many useful javascripts for use in .Net, including a popup
window that can be attached to almost any .net object be it a button, drop
down, or whatever.

The component is free and you can download a help file for it and the full
source code. Just go to my site, www.aboutfortunate.com, click on the code
library link and then click on the Javascript button in the menu on the
left.

--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

Free code library at:
www.aboutfortunate.com

"Out of chaos comes order."
Nietzche


Hi there, please help on why this is happening:
I have tried to the following on my button click event, nothing is
happening, no pop up new window. I could not think of anything wrong here.
'********
Private Sub btnCalculate_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnCalculate.Click

If CheckBalance() = 1 Then

Dim str As String = "<script language=""javascript"">" & _

" function openpopup(){ " & _

"winpops = window.open(""co2.aspx"", """",
""alwaysRaised,width=400,height=338,"")" & _

"} " & _

" openpopup();" & _

"</script>"

Response.Write(str)

End If

End Sub

'********
 
Thanks a lot for responding with such a speed!

now pop up window is out, but it won't stay on top even through I userd
"alwaysRaised":
*************
If CheckBalance() = 1 Then

If Not Page.IsClientScriptBlockRegistered("PopUpWindowv10") Then

Dim msbHTML As New System.Text.StringBuilder()

msbHTML.Append("<script language=""javascript"">" & vbCrLf)

msbHTML.Append("window.open('co2.aspx', '',
'alwaysRaised,width=400,height=338,')" & vbCrLf)

msbHTML.Append("</script>" & vbCrLf)

Page.RegisterClientScriptBlock("PopUpWindowv10", msbHTML.ToString)

End If

End If

************************************
 
Ok, I got it.
I used window.alert instead of window.open to put pop up window stays on
top of all other windows.

Thanks.
 
Back
Top