Click here to Skip to main content
15,881,139 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
Hi
I'm trying to make an application in which i need to open popups, this is an online gaming site. The page from which i'm opening popups is tournament.aspx, this is an ajax enabled page. I'm opening the popup window with a game on the click of 'Take your seat' button in the page tournament.aspx.

I'm using the following code for opening the popup

sb.Append("window.open('popuppage.aspx','','width=500, height=550,menubar=no,resizable=yes,scrollbars=yes');");
ScriptManager.RegisterClientScriptBlock(this.btnTakeSeat, this.GetType(), "hello", sb.ToString(), true);


But using this code, a new popup window will be opened for each button click.

I want multiple popups, but the popup with an id should not be opened again until it is closed

Is there any way to check whether the popup corresponding to an id is open

Thanks

Nidhin
Posted

I don't find any ID assigned to the new windows created!
Try this:
sb.Append("var myWin = window.open('popuppage.aspx','',
'width=500, height=550,menubar=no,resizable=yes,scrollbars=yes');");
ScriptManager.RegisterClientScriptBlock(this.btnTakeSeat, 
                      this.GetType(), "hello", sb.ToString(), true);

Now only one window will be opened at this button click. If you press again, it will re-open in the same one.

Look here for more details on it, if needed: MSDN: open Method[^]
 
Share this answer
 
v2
For that you can have a flag for each id on parent page.By default set it false .Whenever you open a popup,set it true and when close set it false.Always check the flag before opening popup,open it only when it is false.
 
Share this answer
 
How do i know whether the pop has closed..how do i get it in the asp page
 
Share this answer
 
You can use following code to open single window every time.

C#
var newwindow;
function popupwindow(url)
{
    newwindow=window.open(url,'name','width=500, height=550,menubar=no,resizable=yes,scrollbars=yes');
    if (window.focus) {newwindow.focus()}
}



Just you need to register this script code with script manager.

The window.focus will check whether it is available or not. if not then it will open new window and focus on it.

If window.focus is not working then also you can checked "newwindow.closed" property to verify that popwindow is closed or not.
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900