Click here to Skip to main content
15,891,431 members
Please Sign up or sign in to vote.
4.27/5 (4 votes)
I am using following code to open a aspx page as popup.
C#
btnSearch.Attributes.Add("onclick", "Javascript:var PopUpWin = window.open('SearchPR.aspx','_blank','width=600,height=380,title=yes,toolbar=no,location=no,resizable=no,status=no');return false;")

My issue is if the popup window is already open, i dont want to open it again. Right now, if popup is already open, and i click the btn again, it open another popup window.

How do I fix this?
Posted
Updated 8-Mar-11 10:55am
v2
Comments
Sergey Alexandrovich Kryukov 8-Mar-11 16:53pm    
I would suggest you remove all tags except Javascript, they are irrelevant.
This is a valid Question and a very typical issue, so I vote 5.
--SA
Member 13319399 21-Jul-17 2:25am    
How can i insert the listbox in pop up window?? Then assign that item in the list box to textbox through click event??

replace "window.open" by "window.showModalDialog"

For detail please navigate

If you have more concerns, please let me know.
 
Share this answer
 
v2
Comments
Rubaba 9-Mar-11 15:06pm    
exactly 5.
The below script might be useful -

<script language="JavaScript"><!--
var windowHandle = null;
var windowHandle_closed = false;

function openWindow() {
    windowHandle = window.open('SearchPR.aspx','_blank','width=600,height=380,title=yes,toolbar=no,location=no,resizable=no,status=no');
    if (windowHandle_closed) {
        windowHandle_closed = false;
    }
}

function closeWindow() {
    if (windowHandle != null) {
        if (!windowHandle_closed) {
            windowHandle_closed = true;
            windowHandle.close();
        }
    }
}
//--></script>




HTH
Rajeev


Please vote and mark the answer as accepted if this helps

 
Share this answer
 
Give same name to the new windows and it will open in the same window all the time.

Right now, you must be using different name in all the cases for the new window. This forces to open in the different one and not in the existing one only.

For ex: 'myWindowName' is the name that needs to be same all the time.
JavaScript
var reportWindow = window.open('CostByProject.aspx', 'myWindowName','height=650,width=900,resizable=1,status=yes,scrollbars=1,toolbar=no,menubar=no,location=no');


Read the details here: MSDN: Window.Open()[^]

P.S.: "_blank" will always trigger a new window. Replace it with a fixed name and you will be set.
 
Share this answer
 

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