Button open a new page

  • Thread starter Thread starter Mariame
  • Start date Start date
M

Mariame

Hi everyone
I have a button that open a new web page so i use the following script
response.write("<script>window.open(url,'Name')</script>")
every time the user click on the button it opens a new page
How to make sure that if the user open a page & click again on the button it
doesent open another one as long as the page is already opened??????????
Thx & Regards
 
When you submit your form, you're breaking the ownership chain between the
form and the window that you named 'Name'. Therefore, when you run your
script again, it has no knowledge of the window named 'Name'.

If you did this entirely in HTML controls and on the client side, it would
work as expected.

Dale Preston
MCAD, MCSE, MCDBA
 
Mariame,
Add a button and a label to a form and try the following code to the
buttons click event
Jared

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
Dim urls() As String = New
String("http://www.microsoft.com,http://www.google.com,http://www.amazon.com,http://www.yahoo.com").Split(",")

Select Case Me.Label1.Text
Case 0 To 3
Me.Label1.Text += 1
Case Else
Me.Label1.Text = 0
End Select

Dim URL As String
If Me.Label1.Text >= 4 Then
Me.Label1.Text = 0
End If
URL = urls(Me.Label1.Text Mod 4)

Dim MyScript As New System.Text.StringBuilder
With MyScript
.Append("<script language=""javascript"">")
.Append("window.open('" & URL & "','Name');")
.Append("</script>")
End With
Page.RegisterStartupScript("SingleWindow", MyScript.ToString)
End Sub
 

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

Back
Top