Question

I have an asp.net website StartPage that does not require signing-in, in order to view it. On this StartPage, there is a Login linkbutton that when clicked opens a small Login popup page. Unfortunately, after the user has entered their loin credentials and clicks login, the destination page loads in the same popup window which is not my desired result.

What i would like is when the user has successfully been authenticated, the popup Login window should close and redirect the user to the destination page, but this destination page should load in the original main window.

This is the function that opens the popup windows

 function PopupCenter(pageURL, title, w, h) {
            var left = (screen.width / 2) - (w / 2);
            var top = (screen.height / 2) - (h / 2);
            var targetWin = window.open(pageURL, title, 'toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=no, copyhistory=no, width=' + w + ', height=' + h + ', top=' + top + ', left=' + left);
        }           

And the linkbutton OnClient property is like so

 <asp:LinkButton ID="LinkButton2" runat="server" 
    onclientclick="PopupCenter('Login.aspx', 'myPop1',400,300);">Log Me In</asp:LinkButton>
Was it helpful?

Solution

This is impossible with this approach, I mean you should avoid using window.open. Instead you can create your custom pop-up (for example using divs). On this pop-up you will need to create same HTML elements as in your "Login.aspx" page and the same sever logic too. Than you will need to modify your PopupCenter function to open your custom pop-up instead of using window.open.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top