Am I a Popup?
One way of determining if the current page is a popup or not, is to check the Request.UrlReferrer. If the object is Nothing, it is safe to assume that the page is a popup. However, during subsequent page loads, the UrlReferrer changes - to the active page! One work around is displayed below:
If Request.UrlReferrer Is Nothing OrElse Not String.IsNullOrEmpty(Request.Form("__IsPopup")) Then
Master.isMenuVisible = False
SearchMenu.Visible = False
btnBack.OnClientClick = "window.close()"
ClientScript.RegisterHiddenField("__IsPopup", True)
End If
By Registering a HiddenField with a clever name, you can have your page remember that it is a popup window and act accordingly.
Comments