Let's say I have two pages: Main.aspx and Popup.aspx
On my Main.aspx, I have a button named btnShowPopup. When the user clicks the button, Popup.aspx appears on a new window.
ScriptManager.RegisterClientScriptBlock(Me, Me.GetType(), "showpopup", "window.open(Popup.aspx','" & GetPopupName() & "','menubar=0,status=0,resizable=1,scrollbars=1,toolbar=0');", True)
The GetPopupName returns a unique ID that is used to name my popup window on load.
My function looks like this:
Private Function GetPopupName() As String Session("PopupName") = Guid.NewGuid().ToString().Replace("-", String.Empty) Return Session("PopupName") End Function
My function, GetPopupName() for this form has this code:
Public Function GetPopupName() As String If Not Session("PopupName") Is Nothing Then Return Session("PopupName") Else Return "Invalid" End If End Function
Now, I am successful at allowing the user to open the page in a popup window via the button, btnShowPopup, and at preventing the user from opening the page via typing the URL manually. But what I want to do is to prevent the user from opening the popup again if the popup is already opened.
With my current codes, if I click btnShowPopup, a new window with Popup.aspx opens. If I click it again, it opens again.
I want to have a behavior just like in windows when the form is prevented to have multiple instances open.
Does anyone know of a way to achieve this?
This post has been edited by November-06: 09 May 2012 - 09:30 PM