window.radopen not working

12 posts, 0 answers
  1. Jeff P
    Jeff P avatar
    37 posts
    Member since:
    Mar 2007

    Posted 30 Jul 2008 Link to this post

    I am trying to open a Rad Window via client-side script upon taking some server-side action.

    I have a function:

    function

    ShowUpdateForm()

    {

    window.radopen("REPUpdate.aspx","RW1");

    return false;

    }

    I call this function from an update on the server side by using the "InjectScriptLabel" solution.

    InjectScriptLabel.Text =

    "<script>ShowUpdateForm();</script>"

    When the page goes to run my function I get this script error:

    Error:  "object expected."

    My window manager and window are defined as follows:

    <

    telerik:RadWindowManager ID="rwm1" runat="server" Skin="Office2007" Behavior="Default"

    InitialBehavior="None" Left="" Top="">

    <Windows>

    <telerik:RadWindow ID="RW1" runat="server" Behavior="Default" InitialBehavior="None"

    Left="" NavigateUrl="" Style="display: none;" Top="" Title="REP Code Changes"

    Height="200px" Width="450px" Modal="True" ReloadOnShow="true" >

    </telerik:RadWindow>

    </Windows>

    </telerik:RadWindowManager>

    It seems to me the window.radopen command is not being recgonized.

    Any thoughts?

  2. Svetlina Anati
    Admin
    Svetlina Anati avatar
    2795 posts

    Posted 30 Jul 2008 Link to this post

    Hi jalmto,

    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 RadWindowManager) in the Sys.Application.add_init() method.

    Here is how the client events are fired in the page life cycle:

    window.onload -> Sys.Application.init -> Sys.Application.load

    You can see that the client object representation of MS AJAX controls are created just as the last code on the page in the Sys.Application.init event, which is raised after the window.onload event.

    That is why when you call your code in window.onload by executing the client script through the label, the RadWindowManager will still not be created on the page and you will get an error. To avoid this problem, you can either execute your code with a small timeout, or use the Sys.Application.add_load method.

    I also strongly recommend to try showing the RadWindow from the server by setting its VisibleOnPageLoad property to true in the particular eventhandler  because this approach is better and it is used in most scenarios as yours.

    You can find additional inoformation about this here.

    Greetings,
    Svetlina
    the Telerik team


    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Jeff P
    Jeff P avatar
    37 posts
    Member since:
    Mar 2007

    Posted 30 Jul 2008 Link to this post

    Ok, I am NOT wanting to load the window when the page loads.  I want the window to load from the UpdateCommand on the RadGrid.  If a sertain condition exists, then I want to load the window, otherwise I do not want to load the window.

    I had this working server side until I realized I needed to update the grid when I was done with the window.  All the examples on your site do this with  AJAX.  Since then I am having all sorts of problems.  I actually prefer not to use AJAX as it's a pain in the A##!

    So, I either need:

    a.> A solution to update the grid of the calling page from the window without the use of AJAX.

    OR

    b.> An answer as to why the client command "window.radopen" is throwing an "object expected" error.

  5. Svetlina Anati
    Admin
    Svetlina Anati avatar
    2795 posts

    Posted 01 Aug 2008 Link to this post

    Hello jalmto,

    1. You can use the built-in javascript __doPostBack function in order to perform a postback instead of an ajax request as shown in the attached project. Please, note that this is not directly related to the RadControls but it is a general ASP.NET and javascript knowledge. You can find more information about it here.

    or

    2. As discussed in our previous answer, the reason for ShowUpdateForm() throwing an exception when you call it is that you inject it in the body page, and when the browser parses it - it tries to execute it. When it calls the window.radopen function, under the hood of this function there is an attempt to find a RadWindowManager object.
    Since all MS AJAX controls are created at the time of page load, and your code executes prior to page load - no
    RadWindowManager object is found, and error is thrown.

    This is why, to get things working, you should make sure that your code executes after the page is loaded.
    There are a number of ways to do that, but one possibility is to wrap your function invocation in a Sys.Application.add_load event handler, e.g.:

    function ShowUpdateForm()
    {
       Sys.Application.add_load(function()
        {
            window.radopen(
    "REPUpdate.aspx","RW1");
        });
       return
    false;
    };


    Sincerely yours,
    Svetlina
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
  6. Jeff P
    Jeff P avatar
    37 posts
    Member since:
    Mar 2007

    Posted 01 Aug 2008 Link to this post

    Thanks for your response!

    I tried the __doPostBack previously and it did not work as I wanted.  I did however, come up with a solution to solve my problem.  I didn't want to use AJAX on this page so I removed it and that solved the problem of loading my window.  Then I was left with the issue of updating of the grid after the RADWindow closed.  So, taking the idea from your examples, intead of using the AJAXManager as my avenue to update it, I used the click event on a command button.

    Works like a charm!
    Thanks again!
    Jeff
  7. Baris
    Baris avatar
    5 posts
    Member since:
    May 2011

    Posted 18 May 2011 Link to this post

    function ShowUpdateForm()
    {
       Sys.Application.add_load(function()

    this approach hasnt solved my problem. I'm still getting "GetRadWindowManager is not defined" or "radopen is not defined" (depending on which one i use)

    "this is why, to get things working, you should make sure that your code executes after the page is loaded.
    There are a number of ways to do that,"

    may i hear those other ways?
  8. Marin Bratanov
    Admin
    Marin Bratanov avatar
    3595 posts

    Posted 19 May 2011 Link to this post

    Hi Baris,

    I would recommend examining the following blog post for more information on the matter: http://blogs.telerik.com/supportdept/posts/09-05-05/executing_javascript_function_from_server-side_code.aspx and the links at the bottom of the post as well.

    The general idea is that the control you reference should be loaded. The most common way to do that is to use the Sys.Application.Load event, of course, yet you can also use partial page postbacks (also called callbacks or AJAX requests) so that the desired control is not disposed on the client at all. You could, of course, just add a timeout to your function in hopes that the page will have loaded for that time, but I would not recommend it.



    Kind regards,
    Marin
    the Telerik team

    Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.

  9. Baris
    Baris avatar
    5 posts
    Member since:
    May 2011

    Posted 20 May 2011 Link to this post

    i tried at least a dozen ways. just before going crazy, realized the windowmanager visible is set to "false" and it was the cause
  10. Garry
    Garry avatar
    43 posts
    Member since:
    Sep 2012

    Posted 27 Feb 2012 Link to this post

    The tip for using Sys.Application.add_load(function() is absolutely priceless.
    I could not find any examples of using it in your on-line samples - please consider adding this to your future examples as it is a key enabler for driving modal dialogues from server code, using some Javascript of course.
  11. Marin Bratanov
    Admin
    Marin Bratanov avatar
    3595 posts

    Posted 28 Feb 2012 Link to this post

    Hi Garry,

    There is a sticky thread that shows how to open a RadWindow from the server: http://www.telerik.com/community/forums/aspnet-ajax/window/opening-radwindow-from-the-server.aspx. It is not part of our examples, since originally it is not in the design of the control (but it is, however, placed in the documentation here). The RadWindow should be used with JavaScript and is not rendered on the server, which is one of the paradigms in its creation. This means that is should, generally, not be opened on the server, and indeed, this approach opens it via JavaScript on the client.


    Kind regards,
    Marin
    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.
  12. Raymond
    Raymond avatar
    19 posts
    Member since:
    Aug 2013

    Posted 10 Dec 2013 Link to this post

    Why don't you put this in your examples? I find the examples on your site to be very incomplete.
  13. Marin Bratanov
    Admin
    Marin Bratanov avatar
    3595 posts

    Posted 11 Dec 2013 Link to this post

    Hello Raymond,

    We need to find some balance between having too many demos where people will get lost and a small number that showcase the control features by themselves. We have added some example that show common functionality and common scenarios, other cases are described in the control's documentation or our knowledge base articles. The case with opening a RadWindow from the server is not a control feature, but a specific scenario that is also available in our online documentation: http://www.telerik.com/help/aspnet-ajax/window-troubleshooting-opening-from-server.html.
    We do try to cover most common cases and there are resources available for them. Nevertheless, if you share with us what you find lacking we will take your feedback into account.


    Regards,
    Marin Bratanov
    Telerik
    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 the blog feed now.
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017