Suppressing modal popup after first view
-
Here's something I had trouble getting information about. I added an Ajax modal popup extender to our home page to display a temporary message in a panel. The user could close it manually and a timer closed it automatically after 10 seconds. But if the user navigated away from the home page and then returned, the popup did too, annoying said user and me too. It seemed that it could be suppressed using session state. Trouble was, using IsSessionNew just was not working. After trying many red herrings, this is what worked for me: IsSessionNew seems to not activate until a variable is put into the session. So I made a session variable when the popup is invoked (ModalPopup_ResolveControlID) and used a hidden field to store it (Session("NewSession") = "X") and used that as the target ID of the Ajax ModalPopupExtender. Then I could continue with the show/hide logic.
If Not IsPostBack Then
If Session.IsNewSession Then
ModalPopup.Show()
Timer1.Enabled = True
Else
ModalPopup.Hide()
End If
End IfThe timer is in an Ajax timer control within the panel that is popped up. That needs to be suppressed after the first tick or the screen flickers every 10 seconds. On Timer1_Tick, Timer1.Enabled = False