|
-
May 4th, 2005, 07:07 AM
#1
Thread Starter
Fanatic Member
Javascript Conditional Popup Window Open
Hi ...
I have an aspx page with VB as the code behind. I want to conditionally open a popup window with Javascript when a button is clicked on the aspx page. For example:
Code:
If all checks are okay then
Open Popup Window with Javascript
End If
Is this possible? In the examples I've seen, the window is always opened when the button is clicked.
Thanks!
-
May 4th, 2005, 07:57 AM
#2
Fanatic Member
Re: Javascript Conditional Popup Window Open
Yes, use an if statement like you have done above.
if checks are ok then u can use the following code
Response.Write("<script language=javascript>window.open('http://www.google.com',null,'height=200, width=400,status= no, resizable= yes, scrollbars=no, toolbar=no,location=no,menubar=no ');</Script>")
-
May 4th, 2005, 08:51 AM
#3
Re: Javascript Conditional Popup Window Open
You could also use Page.RegisterStartupScript() with your javascript string there.
-
May 4th, 2005, 09:35 AM
#4
Thread Starter
Fanatic Member
Re: Javascript Conditional Popup Window Open
Thanks guys! Mendhak, in my research, I saw "Page.RegisterStartupScript()" but I didn't see how I could incorporate it with an IF statement to only display the popup if certain conditions were met.
Thanks again.
OneSource
-
May 4th, 2005, 10:26 AM
#5
Re: Javascript Conditional Popup Window Open
Use vb:
VB Code:
Private Sub ibtEnter_Click(ByVal sender As System.Object, ByVal e As System.Web.UI.ImageClickEventArgs) Handles ibtEnter.Click
If ValidateFields() Then
MessageBox("Im Okay")
End If
End Sub
VB Code:
Private Sub MessageBox(ByVal sMessage As String)
'Do not send message strings that include an apostrophe
sMessage = "<script>" + "alert('" + sMessage + "');" + "</script>"
Page.RegisterStartupScript("ClientSideScript", sMessage)
End Sub
-
May 4th, 2005, 10:44 AM
#6
Thread Starter
Fanatic Member
Re: Javascript Conditional Popup Window Open
Kewl, Wild_Bill - thanks!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|