Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Code to wait for pop up 1

Status
Not open for further replies.

niall29

Technical User
May 1, 2003
38
GB
Hi,
I hope you can help but my problem is,
I have a web page that does some lengthy searches.
I have put code in so that when a user presses the Search button it will open a popup saying SEARCHING (flashing) so they know that their computer has not hung and then goes to the rest of the code which is connecting to the Db and doing the search.
Anyway what is happening is that my program is reading the code to open the popup and going straight into the search so my pop up doesn't come up until the search has ended.

Can anyone help so I can get the popup to come first and not go to the next bit of code until it has opened.

Thanks in advance
 
How have you added the code to the page at the moment?


____________________________________________________________

Need help finding an answer?

Try the Search Facility or read FAQ222-2244 on how to get better results.

 
This is what I have

Private Sub btnSearch_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSearch.Click

Create_popup()

Acct_Search()


Public Function Create_popup()

Dim popupScript As String = "<script language='javascript'>" & _
"window.open('Search.aspx', null," & _
"'width=130, height=160, channelmode=no, url=no, location=no, titlebar=0, status=0, directories=0, menubar=0,left=300, top=250, toolbar=0, resizable=0')" & _
"</script>"

Page.RegisterStartupScript("PopupScript", popupScript)
End Function
 
Yes, that's because you are telling the code to run once the page is loaded (RegisterStartupScript). Instead, when the page loads, I'd add a pop-up dialog to the Button itself. This way, the pop-up will b launched when the Button is pressed and before the request is sent back to the server.


____________________________________________________________

Need help finding an answer?

Try the Search Facility or read FAQ222-2244 on how to get better results.

 
Thanks for your help
but unfortunately I dont know how to do it without using
Page.RegisterStartupScript("PopupScript", popupScript)
I have moved the code to the button event but how do I tell it to open straight away
 
You can add the relevant javascript to the Button on the Page Load event by using:
Code:
myButton.Attributes.Add("onclick", "")
and pass in the window.open method as the second argument.


____________________________________________________________

Need help finding an answer?

Try the Search Facility or read FAQ222-2244 on how to get better results.

 
Thanks for the help. I haven't tried it yet but it makes since
 
i put this line of code in the page Load event

btnSearch.Attributes.Add("onclick", "<script language='javascript window.open('Search.aspx', null,width=130, height=160, channelmode=no, url=no, location=no, titlebar=0, status=0, directories=0, menubar=0,left=300, top=250, toolbar=0, resizable=0')</script>")

but it didnt work
 
niall29 ,

Get rid of the <script language=javascript. It should look like:

Code:
btnSearch.Attributes.Add("onclick", "window.open('Search.aspx', 'null,width=130, height=160, channelmode=no, url=no, location=no, titlebar=0, status=0, directories=0, menubar=0,left=300, top=250, toolbar=0, resizable=0')")
 
I don't know what I am doing wrong but now the pop up doesn't come up at all.
I put that code in the page load event and commented out my
Dim popupScript As String = "<script language='javascript'>" & _
"window.open('Search.aspx', null," & _
"'width=130, height=160, channelmode=no, url=no, location=no, titlebar=0, status=0, directories=0, menubar=0,left=300, top=250, toolbar=0, resizable=0')" & _
"</script>"
on the button click event and now the popup doesn't open at all
Please help....
 
So what does your Page Load event loook like now?


____________________________________________________________

Need help finding an answer?

Try the Search Facility or read FAQ222-2244 on how to get better results.

 
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

btnSearch.Attributes.Add("onclick", "window.open('Search.aspx', 'null,width=130, height=160, channelmode=no, url=no, location=no, titlebar=0, status=0, directories=0, menubar=0,left=300, top=250, toolbar=0, resizable=0')") '' Label1.Text = System.Security.Principal.WindowsIdentity.GetCurrent().Name


Is this right
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top