ASP.NET - Single instance for a page in asp.net

Asked By gopal krish on 22-Feb-12 09:15 AM
hi..

i am having a gridview in that i was loading images and then i have a link button inside grid to enlarge the image in a separate page.(pop up window)

now i was opened the pop up window and its show the image but i didnt close the popup window and then click the next row link button inside the grid.

here the page was not to be opened. because its already opened. so i want to show a message box"a.aspx already opened."

when i close the popup window then only i can able to view another image in the pop up window..
how to do this..

nedd ur suggetsions

regards
gopal.s
Venkat K replied to gopal krish on 22-Feb-12 10:51 AM

You can check to see if the window has been opened then subsequently closed with the below code:
<script language="JavaScript">
var windowHandle = null;

function openWindow() {
    windowHandle = window.open('http://www.irt.org/','windowName','height=200,width=200');
    if (!windowHandle.closed)
      window.closed = false;
}

function closeWindow() {
    if (windowHandle != null) {
      if (windowHandle.closed) {
        // already opened and closed
      }
      else {
        windowHandle.closed = true;
        windowHandle.close();
      }
    }
    else
      // not yet opened
}
</script>

Thanks

kalpana aparnathi replied to gopal krish on 22-Feb-12 01:48 PM
hi,

Try below code:
Popup p = new Popup();
 
    public void GetPuopup(Popup sender)
    {
      p = sender as Popup;
    }
 
    private void ucBtn_Click(object sender, RoutedEventArgs e)
    {
      ucPopup.IsOpen = true;
 
      if (ucPopup.IsOpen==true)
      {
        p.IsOpen = false;// Here to access the popup from Maipage
      }
      else
      {
        p.IsOpen = true;
      }
    }
In MainPage code behind:
 
    private void b1_Click(object sender, RoutedEventArgs e)
    {
      myUc.GetPuopup(pupup1);
 
      pupup1.IsOpen = true;
      if (pupup1.IsOpen==true)
      {
        myUc.ucPopup.IsOpen = false;
      }
      else
      {
        myUc.ucPopup.IsOpen = true;
      }
    }
 
Hope this will help!!!!!1