function
ShowWindow()
{
var omanager = GetRadWindowManager();
var ownd = omanager.getWindowByName("DialogWindow1");
ownd.show();
}
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<telerik:RadWindowManager id="Singleton" runat="server" ClientCallBackFunction="ResetPasswordWindowClosed" >
<windows>
<telerik:RadWindow id="DialogWindow1"
Modal = "true"
Runat="server"
Width="600px"
Height="250px"
Title="Reset Password"
NavigateUrl="~/Support/ResetPassword.aspx"
Skin="WebBlue"
VisibleStatusbar="false"
Behavior="Close"
>
</telerik:RadWindow>
</windows>
</telerik:RadWindowManager>
//and in code behind
public void OpenResetPasswordWindow()
{
literalInjectJavascript.Text = "<script type='text/javascript'> ShowWindow(); </script>";
}
I've tried numerous different examples from telerik site but whenever I call GetRadWindowManager() the result is always 'undefined'.
Your help is most appreciated as I've spent most of the day trying to get this working.
Thankyou
10 Answers, 1 is accepted
The controls in the RadControls for ASP.NET AJAX suite are built upon the MS AJAX framework and the framework itself creates its controls (including RadWindow) in the Sys.Application.add_init() method - you can check this for yourself by examining the HTML dump of a page with RadControls for ASP.NET AJAX included in it (or any other ASP.NET AJAX control).
That is why when you try to obtain a reference to the RadWindowManager its client object is still not created. To correctly reference it you should add a load handler as shown below:
literalInjectJavascript.Text = "<script type='text/javascript'> Sys.Application.add_load(ShowWindow); </script>"; |
Another option is to execute your code with a small timeout.
For your convenience I am attaching your modified code.
Sincerely yours,
the Telerik team
Instantly find answers to your questions at the new Telerik Support Center

Thanks

Mine's a bit different though, in that I'm using it on the MasterPage, calling it from a Menu. Here's where it's called:
<telerik:RadMenuItem runat="server" Text="Bookmarks">
<Items>
<telerik:RadMenuItem runat="server" Text="Bookmark Page" NavigateUrl="javascript:Bookmark();">
</telerik:RadMenuItem>
</Items>
</telerik:RadMenuItem>
Here's the Window Manager:
<telerik:RadWindowManager ID="windowMgr" runat="server" ReloadOnShow="true">
<Windows>
<telerik:RadWindow
ReloadOnShow="true"
NavigateUrl="~/Bookmarks/AddBookmark.aspx"
ClientCallBackFunction="TriggerEvent"
runat="server"
Height="400"
Width="400"
ID="BookmarkWindow"
Behavior="Close,Resize,Move"
VisibleStatusbar="false" IconUrl="../favicon.ico" Modal="true">
</telerik:RadWindow>
</Windows>
</telerik:RadWindowManager>
And the javascript:
function Bookmark()
{
var omanager = GetRadWindowManager();
alert(omanager); //Always shows undefined
var ownd = omanager.getWindowByName("BookmarkWindow");
ownd.show();
}
So with what I have to work with, I can't really do an onclick and add in that add_load function since I can't add an onclick to the RadMenuItem. I tried to put it right into it like this:
<telerik:RadMenuItem runat="server" Text="Bookmark Page" NavigateUrl="javascript:Sys.Application.add_load(Bookmark());">
But that doesn't work either.
Any ideas for me?
Thank you,
Chris
I tested your code and it works as expected on my side, the RadWindowManager object is referenced and a RadWindow opens. Furthermore, in your particular case you do not have to add a load handler, because when you click on the menu item you actually do not perform a postback.
Please, find my test project attached and test it on your side.
In case you still experience problems, prepare a new, fully runnable project or modify mine in order to reproduce the described behavior, open a new support ticket and send it to me. Once I receive it, I will locate the problem and I will modify it in order to meet your requirements.
Greetings,
Svetlina
the Telerik team
Instantly find answers to your questions at the new Telerik Support Center

I think I am having a similar problem. I am trying to load the radwindow as soon as a page opens on first load. To do this I have a openWin JS function used to call radopen to open the radwindow. I have tried 2 methods to call my JS function but I get the undefined method with both. I the page load I have tried:
ScriptManager
.RegisterStartupScript(this, typeof(string), "OPEN_WINDOW_C", "openWin('QuoteCompare2.aspx',0);", true);
AND
InjectScript.Text =
"<script type='text/javascript'> Sys.Application.add_load(openWin('QuoteCompare2.aspx',0));</script>";
Inside my JS openWin function I also get undefined for the following:
var oManager = GetRadWindowManager();
alert(oManager);
Can anyone help.
Thanks in advance.

ScriptManager
.RegisterStartupScript(this, typeof(string), "OPEN_WINDOW_C", @"window.setTimeout(""openWin('QuoteCompare2.aspx',1)"",500);", true);


The Timeout like Eugene describes is working for me, too!

I'd just like to point out that this is not a bug, but the general way the frameworks is designed and should be used. As for previous posts regarding the need for timeout with the Sys.Application.add_load() method - it only takes the name of the function to be executed, not an entire function, more details and an example of using the approach can be found in this help article: http://www.telerik.com/help/aspnet-ajax/radwindow-troubleshooting-javascript-from-server-side.html.
Greetings,
Marin
the Telerik team