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

[Solved] How to open a RadWindow from code

6 Answers 237 Views
Window
This is a migrated thread and some comments may be shown as answers.
Ed
Top achievements
Rank 1
Ed asked on 04 Nov 2009, 10:40 PM
Hi there,

Is it possible to open a RadWindow from server-side code instead of clicking on the element specified in the Window.OpenerElementID?  I need to load some data into the Session just before the window is opened, so that I can refer to it in the code-behind file of the window's destination page.

Thanks,

Ed Graham

6 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 05 Nov 2009, 06:03 AM
Hi Ed,

Try the following code snippet which shows how to open RadWindow from code behind.

cs:
    protected void Button1_Click(object sender, EventArgs e) 
    { 
        RadWindowManager windowManager = new RadWindowManager(); 
        RadWindow widnow1 = new RadWindow(); 
        // Set the window properties 
        widnow1.NavigateUrl = "Window1.aspx"
        widnow1.ID = "RadWindow1"
        widnow1.VisibleOnPageLoad = true// Set this property to True for showing window from code 
        windowManager.Windows.Add(widnow1); 
        this.form1.Controls.Add(widnow1); 
    } 

You can also checkout the following documentation for more information:
Setting Server-Side Properties

-Shinu.
0
Accepted
Georgi Tunev
Telerik team
answered on 05 Nov 2009, 11:54 AM
Hello Ed,

You can open the RadWindow from the server by setting its VisibleOnPageLoad property to true. More information on the subject is available here:
http://www.telerik.com/help/aspnet-ajax/window_settingserversideproperties.html

Best wishes,
Georgi Tunev
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Ed
Top achievements
Rank 1
answered on 05 Nov 2009, 12:02 PM
Hi Shinu,

Thanks for the reply.  Unfortunately, however, that didn't work for me; the window simply doesn't open.  I am calling the code from within a user control rather than a standard ASPX page, as follows:

protected void lnkButton_Click(object sender, EventArgs e) 
    RadWindowManager windowManager = new RadWindowManager(); 
    RadWindow widnow1 = new RadWindow(); 
    // Set the window properties  
    widnow1.NavigateUrl = "http://www.google.co.uk/"
    widnow1.ID = "RadWindow1"
    widnow1.VisibleOnPageLoad = true// Set this property to True for showing window from code  
    windowManager.Windows.Add(widnow1); 
    this.Page.Controls.Add(widnow1); 

Am I doing something wrong?

Thanks for your help,

Ed
0
Georgi Tunev
Telerik team
answered on 05 Nov 2009, 12:27 PM
Hi Ed,

The window must be added inside the form. The easiest way to achieve this is to put a standard asp:placeholder in that form and to add the window there. I also notice that in your code you create a window manager but you don't add it to the form as well.


Best wishes,
Georgi Tunev
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Ed
Top achievements
Rank 1
answered on 05 Nov 2009, 01:51 PM
Thanks Georgi -- that did the trick.
0
Georgi Tunev
Telerik team
answered on 05 Nov 2009, 01:58 PM
Hi Ed,

It is good to know that everything is working fine now. I just want to add something as I see that I missed it in my previous reply - sorry about that.
Note that RadWindow can exist as a standalone control. This means that you can add it to the form, but you will not be able to use radopen() to open it - radopen(), radalert, radconfirm, radprompt, etc. functions belong to the RadWindowManager control.
e.g.
If you create a RadWindowManager and RadWindow controls and add the RadWindow to the RadWindowManager's Windows collection, if you add the RadWindowManager to the form, you will be able to open the newly created RadWindow by using radopen().

If you create only RadWindow control and add it to the form, when you want to open it from the client, you should first get a reference to it and then call its show() method.
for example:
var oWnd = $find("<%= RadWindow1.ClientID %>");
oWnd.show();



Greetings,
Georgi Tunev
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Tags
Window
Asked by
Ed
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Georgi Tunev
Telerik team
Ed
Top achievements
Rank 1
Share this question
or