I need some help. I am using radwindow in one of my projects. The problem is that I am using client side code to open the window. When I open the window, it works fine first time but when i close the window and open again, it doesn't open and gives a javascript error instead. The error is "Object doesn't support this property or method". Upon further verification and trying to make code work i found out that if I remove oWnd.add_close(OnClientClose); from window open function it works well. I don't want to do this as I am using ajax request to postback. Here is the code;
aspx page
<script type="text/javascript">
function openWin(args,width,height)
{
var oWnd = radopen(args, "RadWindow1");
oWnd.setSize(width,height);
oWnd.center();
oWnd.add_close(OnClientClose); //If I remove this then code works.
}
function OnClientClose(sender, eventArgs)
{
$find(
"<%= RadAjaxPanel1.ClientID %>").ajaxRequest("Rebind");
}
function realPostBack(eventTarget, eventArgument)
{
$find(
"<%= RadAjaxPanel1.ClientID %>").__doPostBack(eventTarget, eventArgument);
}
</script>
<
asp:Button ID="addBTN" runat="server" Text="Add Visa Details" />
in code behind
addBTN.Attributes.Add(
"onclick", "return openWin('" + Page.ResolveUrl("~/Controls/visaForm.aspx?n=n") + "', '800', '600'); return false;");
Can some one please help me as I am not very good with javascript.
Thanks
Atiq
11 Answers, 1 is accepted
The code looks fine - could you please open a support ticket and send me a small sample project where the problem can be reproduced? We will check it and get back to you right away.
Regards,
Georgi Tunev
the Telerik team
Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Thank you for the project - I will check it right away.
All the best,
Georgi Tunev
the Telerik team
Check out Telerik Trainer, the state of the art learning tool for Telerik products.
could you please post any updates here also?
Would you please check whether by any chance you have a RadWindowManager which is ajaxified (through the RadAjaxManager or update panel)? If so, please do not ajaxify the RadWindowManager (remove it from the RadAjaxManager settings or move it outside the update panel) and this should fix the problem.
If this is not the case, please open a new support ticket and send a sample, fully runnable project along with detailed reproduction instructions.
Regards,
Svetlina
the Telerik team
Check out Telerik Trainer, the state of the art learning tool for Telerik products.
main composite page:
-this is a content page that uses a master page. the window manager is in here with multiple windows attatched to it. each window has their own OnClientClose event. The page also contains a tab control and multipage. Each tab has its own page (10 tabs/user controls).
userControls:
-each user control has a grid and from here the calls are attatched to open their respected rad window. (calls javascript on the composite page). each user control is wrapped in its own ajaxpanel.
when the window closes, the OnClientClose event on the composite page calls the userControl where it performs an ajaxRequest on that user control to reload/rebind the grid. This works fine but if i go to bring the popup again it doesnt work. ive tried multiple ways to rebind hte control and each way turns out the same.
heres some of the actual code(took out a quick sample of everything and renamed. all javascript is inside telerik radcodeblock. First close works. refresh user control. try to reopen window and it gives a null object javascript error when trying to find the window on the composite aspx)
composite page aspx:
<telerik:RadWindowManager ID="RadWindowManager1" runat="server"> |
<Windows> |
<telerik:RadWindow OnClientClose="OnClientClose" Behavior="Close" DestroyOnClose="true" Skin="Telerik" Height="400px" Width="400px" VisibleStatusbar="false" VisibleOnPageLoad="false" Modal="true" runat="server" ID="Edit1"></telerik:RadWindow> |
</Windows> |
</telerik:RadWindowManager> |
<telerik:RadScriptManager ID="RadScriptManager1" runat="server"></telerik:RadScriptManager> |
<telerik:RadAjaxPanel OnAjaxRequest="RadAjaxPanel1_AjaxRequest" ID="RadAjaxPanel1" runat="server"> |
<telerik:RadTabStrip ID="rts1" runat="server" SelectedIndex="0" Skin="Telerik" MultiPageID="rmp1"> |
<Tabs> |
<telerik:RadTab runat="server" Text="1" Value="1" PageViewID="rpv1" Selected="true"></telerik:RadTab> |
</Tabs> |
</telerik:RadTabStrip> |
<telerik:RadMultiPage ID="rmp1" runat="server" SelectedIndex="0"> |
<telerik:RadPageView ID="rpv1" runat="server"> |
<uc1:profile ID="control1" runat="server" /> |
</telerik:RadPageView> |
</telerik:RadMultiPage> |
</telerik:RadAjaxPanel> |
function OnClientClose(sender, args) { |
ControlRefresh(); |
} |
function ShowPopup() { |
var oWnd = $find("<%=Edit1.ClientID%>"); |
oWnd.setUrl("page.aspx"); |
oWnd.Show(); |
} |
<telerik:RadAjaxPanel OnAjaxRequest="RadAjaxControl_AjaxRequest" runat="server" ID="RadAjaxControl" EnableAJAX="true"> |
<telerik:RadGrid OnItemDataBound="rg1_ItemDataBound" AllowMultiRowSelection="true" ID="rg1" runat="server" AutoGenerateColumns="false" HeaderStyle-Font-Size="Smaller" GridLines="Vertical" HeaderStyle-HorizontalAlign="Center" Font-Size="Smaller" Skin="Telerik"> |
</telerik:RadGrid> |
</telerik:RadAjaxPanel> |
usercontrol javascript:
function ControlRefresh() { |
$find("<%=RadAjaxControl.ClientID %>").ajaxRequest("Refresh"); |
} |
usercontrol code:
protected void RadAjaxControl_AjaxRequest(object sender, AjaxRequestEventArgs e) |
{ |
if (e.Argument == "Refresh") |
LoadControl(); |
} |
Thank you for the provided code, I was able to reproduce the problem.
It comes from the fact that you have set the RadWindow's DestroyOnClose property to true - when you have this setting, when you close the RadWindow, its object is complemetely destroyed. That is why when you open the RadWindow for the first time, it is correctly found and shown. However, next time you want to open it it is already destroyed and a RadWindow with this ID (Edit1) does not exist - that is the reason for the error.
I suggest to remove the DestroyOnClose=true property or in case you really need it in your scenario, you should use the RadWindowManager's radopen method and do not provide an ID when opening the RadWindow as shown below:
radopen(url, null) |
For your convenience I attached my test project with the DestroyOnClose setting removed.
Best wishes,
Svetlina
the Telerik team
Check out Telerik Trainer, the state of the art learning tool for Telerik products.
window declaration:
<telerik:RadWindowManager Modal="true" Behavior="Close" VisibleOnPageLoad="false" ReloadOnShow="true" VisibleStatusbar="false" ID="RadWindowManager1" Skin="Telerik" runat="server">
</telerik:radWindowManager>
javascript call:
var oWnd = radopen("page.aspx", null);
oWnd.set_height(450);
oWnd.set_width(450);
oWnd.add_close(RefreshPage);
Hello cursive34,
What I assume might happen on your side is that your browser is configured to use caching automatically and that is the reason for not seeing a refreshed page. Please do the following setting in IE:
Tools->Internet options->Browsing History->Settings->Check for newer version of stored pages->Every time I visit the web page
and test again. This should fix the problem. Please, note that this is related to browser specifics and configuration and not to RadWindow's functionality.
For your convenience I attached a sample demo project and a video capture - the RadWindow there is opened as in your sample code, the page gets refreshed every time and it is loaded just once.
Let me know how it goes and in case my assumptions are not correct or you need further assistance.
Kind regards,
the Telerik team
Check out Telerik Trainer, the state of the art learning tool for Telerik products.