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
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.
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.
Svetlina Anati
the Telerik team
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.
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