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

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

'********
 
S

S. Justin Gengo

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

'********
 
L

Lily

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

************************************
 
L

Lily

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.
 
Joined
Jun 20, 2008
Messages
1
Reaction score
0
I am using ASP2.0 .net with VB. I have set my site to write code behind.
When applying the same code VB does not recognize "window.open".
Am I missing something
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,767
Messages
2,569,572
Members
45,046
Latest member
Gavizuho

Latest Threads

Top