This is a migrated thread and some comments may be shown as answers.

window will not close even after calling Window.close()

5 Answers 143 Views
Window
This is a migrated thread and some comments may be shown as answers.
digish devassy
Top achievements
Rank 1
digish devassy asked on 16 Jul 2012, 01:45 PM

pop up window which will not close. The only way to close the RadWindow is window.Close () from client side which is not working in this case. 

function GetRadWindow() {

 

 

 

var oWindow = null;

 

 

 

if (window.radWindow) oWindow = window.radWindow;

 

 

 

else if (window.frameElement.radWindow) oWindow = window.frameElement.radWindow;

 

 

 

return oWindow;

 

}

 

 

 

function CloseWin() {

 

 

 

//Get the RadWindow

 

 

 

var oWindow = GetRadWindow();

 

 

 

//Call its Close() method

 

 

 

if (oWindow) {

 

oWindow.Close();

 

 

// alert(oWindow.isClosed())

 

}

 

 

//GetRadWindow().close();

 

 

 

// return false;

 

 

 

//oWindow.close();

 

}

nothing works.

5 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 17 Jul 2012, 04:57 AM
Hi,

Unfortunately I couldn't replicate the problem. Here is the code I tried based on your scenario which works as expected at my end.

ASPX:
<telerik:RadWindow runat="server" ID="RadWindow1" Title="window1" VisibleOnPageLoad="true" NavigateUrl="SecondWindow.aspx" >
</telerik:RadWindow>

SecondWindow.aspx

ASPX:
<asp:Button ID="Button1" runat="server" OnClientClick="return CloseWin()" />

Javascript:
<script type="text/javascript">
 function GetRadWindow()
 {
  var oWindow = null;
  if (window.radWindow) oWindow = window.radWindow;
  else if (window.frameElement.radWindow) oWindow = window.frameElement.radWindow;
  return oWindow;
 }
 function CloseWin()
 {
  var oWindow = GetRadWindow();
  if (oWindow)
  {
   oWindow.Close();
  }
 }
</script>

Thanks,
Princy.
0
digish devassy
Top achievements
Rank 1
answered on 17 Jul 2012, 03:57 PM
the code you showed me works for all other pages I have used radwindow. in this page. I have no idea, window just wont close. I am looking for something like one big time javascript window killer. You give that command and the window will be gone.
0
Svetlina Anati
Telerik team
answered on 19 Jul 2012, 10:36 AM
Hi Digish,

I can make a few assumptions on what could be causing the problem you describe but i need some more information in order to determine which of my assumptions is most likely to be true.

 Can you please provide the following information:

1) Do you use radWindow with ContentTemplate or with NavigateUrl? If you are using ContentTemplate, your code is invalid for this case.

2) From where you want to close the RadWindow - from the parent page where you opened it or from the content page which is inside of radWindow with NavigateUrl? Your code is valid only in case called from content page.

3) Please, make sure you have no js errors on the page. A js error causes unexpected results and your code might not be executed due to that even if it is valid for your scenario.

In case the above notes still do not help you resolve the issue, once we receive the requested information, we will suggest on how to proceed.

Regards,
Svetlina Anati
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
0
digish devassy
Top achievements
Rank 1
answered on 19 Jul 2012, 11:17 AM
1. I am using Navigational URL. I tried the content template, but could not find the function to close the content template one.
2. I am trying to close it from the content page.
3. I am not very sure on Javascript error. I do not remember any other javascript than the one for closeing the radwindow in the content page. But in the parent page. I am not that sure. I will check.

Thanks.

0
Marin Bratanov
Telerik team
answered on 23 Jul 2012, 10:55 AM
Hi Digish,

When working with content pages the beforementioned GetRadWindow() function is necessary to get a reference to the RadWIndow object in order to call the close() method from its own client-side API. There is a major difference between the window.close() method and the close() method of the RadWindow, as the latter is a script control and not a browser window.

I also advise that you examine the ContentTemplate vs. NavigateUrl Online Demo in order to better see the difference between the two modes and how to work with them.


All the best,
Marin Bratanov
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Tags
Window
Asked by
digish devassy
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
digish devassy
Top achievements
Rank 1
Svetlina Anati
Telerik team
Marin Bratanov
Telerik team
Share this question
or