ASP.NET: Open a popup window on first load only?

I need to popup a window when a user successfully logs into my application.

I do not want the popup to open every time they navigate to a page in the application, so I can not put it in the master page.

What is the best way to do this?

So far the best I can think is to pass a query string like firstlogin=true and check that on the master page, and if true, then popup the window? Is there an easier way of doing this?
HADDADD3Asked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Tom BeckCommented:
I'm assuming you mean popup window, but an alert of confirm box would works as well. In Page_Load you could register the pop up javascript and put it in a IsPostBack conditional so it only runs on the initial load.

If Not IsPostBack then
    Dim myScript As String = "newwindow=window.open(""http://www.mydomain.com"",""name"",""height=200,width=150"");if (window.focus) {newwindow.focus()} return false;"
        ClientScript.RegisterClientScriptBlock(Me.GetType(), "myPopUp", myScript, True)
End If
0
dexterrajeshCommented:
the other option would be like pop-up an window using javascript window.open(.....) after the login validation is successful for the user before redirecting to the application home page... you can use the Literal control and set the javascript script strings to that...

all this has to be done in the Login content page where you do the validation for user login..

hope this helps...
0
dejaanbuCommented:
you can have a flag field in your login table. once a person logins, you can put a flag on that field. so if that flag is false, this is the first time for that user.. likewise, you can check...your idea  also seems okay.
0
Big Business Goals? Which KPIs Will Help You

The most successful MSPs rely on metrics – known as key performance indicators (KPIs) – for making informed decisions that help their businesses thrive, rather than just survive. This eBook provides an overview of the most important KPIs used by top MSPs.

HADDADD3Author Commented:
TommyBoy,

Sometimes the page will post back, it is a master page for the entire users area...

The redirect for the login is done from the server side, can i still call it from there?
0
HADDADD3Author Commented:
TommyBoy,

Tried your solution, and it did not work, popup did not open...
0
Tom BeckCommented:
Sorry for the delay in replying, very busy today.

The "return false" should not have been there. It can be made to work from the Master page codebehind but since the master page does not inherit from "Page" you need to add the Page namespace before the ClientScript namespace. Personally, I would put the script in the code behind of the appropriate content page just to have more control over placement, but it will work either way. Here's the corrected code:

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        If Not IsPostBack Then
            Dim myScript As String = "newwindow=window.open(""http://www.google.com"",""name"",""height=200,width=150"");if (window.focus) {newwindow.focus()}"
            Page.ClientScript.RegisterClientScriptBlock(Me.GetType(), "myPopUp", myScript, True)
        End If
    End Sub
0
HADDADD3Author Commented:
Still no luck...And i have it on a content page...
0
Tom BeckCommented:
Just paste this directly into a script block on the page somewhere as a test. Are you sure you don't have popups blocked in your browser? Pop up windows are a bad idea these days. Too many users block them.

newwindow=window.open(""http://www.google.com"",""name"",""height=200,width=150"");if (window.focus) {newwindow.focus()}
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
HADDADD3Author Commented:
Did it as a in page popup
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
ASP.NET

From novice to tech pro — start learning today.