RadWindows with dynamically loaded user control

4 posts, 0 answers
  1. Timothy
    Timothy avatar
    41 posts
    Member since:
    Aug 2011

    Posted 08 Dec 2011 Link to this post

    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
  2. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 08 Dec 2011 Link to this post


    Try the following code snippet to load UserControl in RadWindow.
    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");

  3. Timothy
    Timothy avatar
    41 posts
    Member since:
    Aug 2011

    Posted 08 Dec 2011 Link to this post

    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.
  4. Marin Bratanov
    Marin Bratanov avatar
    5929 posts

    Posted 12 Dec 2011 Link to this post

    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.

    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
Back to Top