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

Dynamically create a radwindow

2 Answers 266 Views
Window
This is a migrated thread and some comments may be shown as answers.
Henry
Top achievements
Rank 1
Henry asked on 08 Mar 2013, 02:07 AM
Hi folks,

I want to dynamically create a RadWindow and add it to the web form. can anyone help with a sample code?

Thanks.
Henry

2 Answers, 1 is accepted

Sort by
0
Accepted
Princy
Top achievements
Rank 2
answered on 08 Mar 2013, 04:17 AM
Hello Henry,

Please have a look at the following code to understand how to create a RadWindow dynamically and add it to your web form.

C#:
protected void createDynamicWindow()
{
    //Create a new window add it dynamically
    //The window will inherit the default settings of parent WindowManager
    Telerik.Web.UI.RadWindow newWindow = new Telerik.Web.UI.RadWindow();
    newWindow.NavigateUrl = "http://www.yoururl.com";
    //Set OpenerElementId - the id (ClientID if a runat=server is used) of a html element, which, when clicked, will automatically open/show the Telerik RadWindow
    newWindow.OpenerElementID = OpenerButton.ClientID;
    //Set OffsetElementID - the id (ClientID if a runat=server is used) of a html element, whose left and top position will be used as 0,0 of the Telerik RadWindow object when it is first shown
    newWindow.OffsetElementID = OpenerButton.ClientID;
    //Top and Left can be used in conjunction with the OffsetElementId (if no OffsetElementId is specified, the top left corner of the browser window is used
    newWindow.Top = Unit.Pixel(22);
    newWindow.Left = Unit.Pixel(0);
    //as a separate control, you can add the newly created RadWindow directly to the form's Controls collection
    form1.Controls.Add(newWindow);
}

Thanks,
Princy.
0
rdmptn
Top achievements
Rank 1
answered on 08 Mar 2013, 07:52 AM
Or use simple JavaScript on the client with the RadWindowManager. This will spare you a postback and recreating controls: http://www.telerik.com/help/aspnet-ajax/window-programming-opening.html.
Tags
Window
Asked by
Henry
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
rdmptn
Top achievements
Rank 1
Share this question
or