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

RadWindows with dynamically loaded user control

3 Answers 309 Views
Window
This is a migrated thread and some comments may be shown as answers.
Timothy
Top achievements
Rank 1
Timothy asked on 08 Dec 2011, 01:00 PM
Is it possible to create a RadWindow in code behind that uses the Page.LoadControl() function and display it. At runtime I need to create an unknown number of RadWindows that are not modal and populate their ContentContainer.Controls with dynamically loaded user controls.

I am using Visual Studio 2010 SP1 with Telerik RadControls for ASP.NET Ajax version 2011.3.1115.40 against the .NET 4 framework

3 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 08 Dec 2011, 01:42 PM
Hello,

Try the following code snippet to load UserControl in RadWindow.
CS:
protected void Page_Load(object sender, EventArgs e)
    {
      RadWindow window = new RadWindow();
      window.Height = Unit.Pixel(500);
      window.Width = Unit.Pixel(500);
      window.VisibleOnPageLoad = true;
      UserControl uc=(UserControl) Page.LoadControl("~/edit_WebUserControl.ascx");
      window.ContentContainer.Controls.Add(uc);
      form1.Controls.Add(window);
    }

-Shinu.
0
Timothy
Top achievements
Rank 1
answered on 08 Dec 2011, 10:05 PM
Hi I tried this code and only one RadWindow shows at one time rather than multiple RadWindows.
The scenario is a MasterPage and ContentPages and since writing this code involves Postbacks and the windows are created dynamically only one window is preserved after each postback.

I have successfully got a scenario working with a RadWindowManager and multiple RadWindows using a NavigateUrl but was concerned with the performance issues of loading whole pages etc. Also had issues with getting jQuery routines to update the contentpage which hosts the buttons that invoke the RadWindow creation.
0
Marin Bratanov
Telerik team
answered on 12 Dec 2011, 09:28 AM
Hello Timothy,

The general approach shown in the previous post is about creating a RadWindow on the server. If you need more than once instance you should simply call this method more than one time. I can advise that you examine this article for more information on creating controls dynamically (short version- the Page Init event). I believe you may also find useful this thread on opening a RadWindow from the server.

As for performance - the main difference between the NavigateUrl and th ContentTemplate is that the page from the URL is loaded only when the RadWindow is shown while the ContentTemplate is always loaded as a part of the main page, thus slowing the initial page load, yet speeding up the loading of the RadWindow. There shouldn't be much of a performance difference with both approaches, the main points to be considered should be user experience and developer comfort.

You can also examine this article on the correct approach of calling JavaScript function between iframes. This is also shown in comparison with the ContentTemplate in this online demo.


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
Tags
Window
Asked by
Timothy
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Timothy
Top achievements
Rank 1
Marin Bratanov
Telerik team
Share this question
or