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

Using radwindow in a user control – upto 20 on a page

3 Answers 128 Views
Window
This is a migrated thread and some comments may be shown as answers.
James
Top achievements
Rank 1
James asked on 01 Oct 2010, 02:42 PM

Hi. We have a user control that has a rad window and rad window manager. The control accepts a couple of parameters (used to build the url to display) and has a few custom events – like window closed that are exposed to the calling page.

 

We now have a requirement to use this control upto 20 times on a single page. I am sure that having the user control on the page 20 times, with 20 different radwindow managers and 20 different radwindows is probably not the best way to do this.

We still want it as a user control as the exact same functionality is required on multiple different pages,  and like wise multiple times on some pages.

What is the best way to achieve this? can you have a single window and manager and share it between all instances of the user control for example?

3 Answers, 1 is accepted

Sort by
0
Cori
Top achievements
Rank 2
answered on 01 Oct 2010, 03:32 PM
Hello James,

I'm guessing it could be possible, as long as the RadWindow being referenced in the UserControls use the same name.

So if you add the RadWindowManager and RadWindow on the page that you will be placing the user controls on, you can access the RadWindowManager from the page by calling GetRadWindowManager() in the user controls, which should return to you the first RadWindowManager registered to the page. From there you can call the RadWindow's like you normally would.

I hope that helps.
0
James
Top achievements
Rank 1
answered on 01 Oct 2010, 03:40 PM
i guess it's a similar conecpt to having a single ajax script manager and multiple ajax controls on a page.....

if you can always get a reference as easily as GetRadWindowManager()  then that does make it fairly easy. i think. i'll have a play and see where i get to
0
Georgi Tunev
Telerik team
answered on 04 Oct 2010, 10:47 AM
Hello James,

Basically - yes, you could have multiple RadWindowManagers per page. In such  case however, you need to take into consideration the following:

   1. All RadWindowManager's functions (radopen, radalert, radconfirm, radprompt, GetRadWindowManager, etc) are always using the first rendered RadWindowManager on the page.
   2. Every RadWindowManager "knows" only the RadWindows that are declared in its Windows collection.

This means that if you have a RadWindow2 declared in RadWindowManager2, and you use something like radopen(myUrl, "RadWindow2");, radopen will use RadWindowManager1 and will open a new RadWindow with the settings taken from RadWindowManager1. To avoid that problem, when you have multiple managers on a page, you need to get a reference to the correct RadWindowManager first and then call its methods.
e.g.
var manager = $find("<%= RadWindowManager2.ClientID %>");
manager.open(myUrl, "RadWindow2");

Sincerely yours,
Georgi Tunev
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
Window
Asked by
James
Top achievements
Rank 1
Answers by
Cori
Top achievements
Rank 2
James
Top achievements
Rank 1
Georgi Tunev
Telerik team
Share this question
or