This is a migrated thread and some comments may be shown as answers.

problem with RadWindowManager in an UserControl

3 Answers 293 Views
Window
This is a migrated thread and some comments may be shown as answers.
SamVanity
Top achievements
Rank 2
SamVanity asked on 20 Nov 2007, 12:45 PM
hi,

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

<telerik:RadWindowManager ID="RadWindowManagerUserControl" runat="server"
    <Windows> 
        <telerik:RadWindow ID="RadWindow1" runat="server" Modal="false" OnClientClose="AfterUpload"/> 
    </Windows> 
</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:

    <telerik:RadWindowManager ID="RadWindowManager1" runat="server"
        <Windows> 
            <telerik:RadWindow ID="RadWindow2" runat="server" Modal="false" OnClientClose="CallBackFunctionEdit"/> 
        </Windows> 
    </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..

3 Answers, 1 is accepted

Sort by
0
Georgi Tunev
Telerik team
answered on 21 Nov 2007, 01:07 PM
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
0
SamVanity
Top achievements
Rank 2
answered on 21 Nov 2007, 03:44 PM
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!
0
Georgi Tunev
Telerik team
answered on 21 Nov 2007, 04:19 PM
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
Tags
Window
Asked by
SamVanity
Top achievements
Rank 2
Answers by
Georgi Tunev
Telerik team
SamVanity
Top achievements
Rank 2
Share this question
or