problem with RadWindowManager in an UserControl

4 posts, 0 answers
  1. SamVanity
    SamVanity avatar
    154 posts
    Member since:
    Apr 2006

    Posted 20 Nov 2007 Link to this post

    hi,

    I have a user control with a RadWindowManager declared as the following:

    1<telerik:RadWindowManager ID="RadWindowManagerUserControl" runat="server"
    2    <Windows> 
    3        <telerik:RadWindow ID="RadWindow1" runat="server" Modal="false" OnClientClose="AfterUpload"/> 
    4    </Windows> 
    5</telerik:RadWindowManager> 

    AfterUpload is a Javascript function declared in the user control as well.

    On the user control, there is a link with the following onclick handler (client side):

    onclick="showWindow('upload.aspx?mode=edit&messageid=388327','RadWindow1', 550, 450); return false;"
    This user control is presently used on two pages.

    HostPage 1 does not contain a RadWindowManager, and the OnClientClose defined in the UserControl fires correctly.

    HostPage 2 has its own RadWindowManager (for other functions), and is defined as the following:

    1    <telerik:RadWindowManager ID="RadWindowManager1" runat="server"
    2        <Windows> 
    3            <telerik:RadWindow ID="RadWindow2" runat="server" Modal="false" OnClientClose="CallBackFunctionEdit"/> 
    4        </Windows> 
    5    </telerik:RadWindowManager> 

    The javascript function CallBackFunctionEdit fires correctly. However, when HostPage 2 opens the RadWindow defined by the user control, the onclientClose function defined in the user control does not fire.

    Questions:

    1) What's wrong? does having 2 RadWindowManagers conflict each other?

    2) If I can only have one RadWindowManager (on the host page), what do you think is the best way to define OnClientClose function for radwindow that should be opened from within the user control? Remember the actual javascript function to handle onclientclose is defined inside the usercontrol..
  2. Georgi Tunev
    Admin
    Georgi Tunev avatar
    7207 posts

    Posted 21 Nov 2007 Link to this post

    Hello Sam,

    The reason for this problem comes from the following facts:
    1. the radopen() function can be used only when a RadWindowManager is declared on the page.
    2. If there are multiple RadWindowManagers on the page, radopen() will use the first rendered manager.
    3. Every manager "knows" only about RadWindows that are declared between its <windows> tags.

    Now in your case, you have 2 RadWindowManagers on the rendered page and the RadWindowManager declared in the UserControl is rendered second. When you call radopen(), the function will use the first RadWindowManager which does not have RadWindow1 declared in it and that is why a completely new RadWindow will be shown which will not have the OnClientClose property set.

    To avoid this confusion I can suggest 2 approaches:

    1. //make sure that you will open the RadWindow from the correct manager  
      var manager = $find("<%=RadWindowManagerUserControl.ClientID %>");  
      var oWnd = manager.open(url, name);  
      oWnd.setSize(width, height);  
       

    2. //an alternative approach: find the needed RadWindow on the page and call its show() method  
      var oWnd = $find("<%=RadWindow1.ClientID %>");  
      oWnd.setUrl(url);  
      oWnd.show();  
      oWnd.setSize(width, height); 


    I hope this helps. For your convenience I've attached to this thread a small sample that shows the described logic.




    Kind regards,

    Georgi Tunev
    the Telerik team


    Instantly find answers to your questions at the new Telerik Support Center
  3. SamVanity
    SamVanity avatar
    154 posts
    Member since:
    Apr 2006

    Posted 21 Nov 2007 Link to this post

    thank you very much for your detailed explanation. I use the alternative approach (define a RadWindow in the user control without the manager), since it is a cleaner approach.

    I just hope you can include more information about the controls in the help page. Thanks again!
  4. Georgi Tunev
    Admin
    Georgi Tunev avatar
    7207 posts

    Posted 21 Nov 2007 Link to this post

    Hi again Sam,


    Indeed, this information and more tips and tricks will be definitely included in the "Prometheus" documentation.



    Best wishes,
    Georgi Tunev
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
Back to Top