Danielle,
Don't attempt to implement it this way - the vast majority of people use
pop-up blockers and it won't work. Windows opening on their own when you
haven't done anything is REALLY REALLY annoying which is why the popup
blocker was invented.
I really don't understand why you're doing it that way in the first
place. If you want a button that opens a window when you click it, just
put the window.open command in the onclick event of that button! Why are
you posting back to the *server* to open a new window client side??
You don't need any server side code for this.
<a href="javascript
:window.open(<blah>)">open me</a>
Ideally, so that it works in browsers which don't have javascript enabled:
<a href="page.html" target="_blank"
onclick="javascript
:window.open(<blah>); return false;">open me</a>
The return false bit prevents it from opening the window using
javascript AND navigating to the site in the background. If the user has
JS disabled, it will still open in a new window, but you won't be able
to specify the size or position of the new window.
Opening the window using client side code only will also be much quicker
as it won't postback to the server before opening the window.
Nick...
Danielle wrote:
Greetings all -
I am working on a vb .NET asp web application. I have a button that
opens a new page when clicked. It works fine; the problem is when the
user refreshes the original page, the script executes again even
though the button hasn't been clicked.
Here's the sub - the button is a standard ASP button with no
frills...
Protected Sub btnNew_Click(ByVal sender As Object, ByVal e As
System.EventArgs) Handles btnNew.Click
Const INSERT_PAGE As String = "AddNewContact.aspx"
Dim URLArg As String = INSERT_PAGE & "?agreementID=" &
agreementID
ClientScript.RegisterStartupScript(Me.GetType, "popup",
"window.open('" & BASEURL & URLArg & "','_blank','menubar=yes')",
True)
End Sub
This is making me a little crazy - any help would be greatly
appreciated. I've seen that others have had this problem, but can't
find any solution yet...
Thanks!
Danielle