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

Opening RadWindow in Server code

2 Answers 111 Views
Window
This is a migrated thread and some comments may be shown as answers.
M Oz
Top achievements
Rank 1
M Oz asked on 28 Jan 2010, 09:54 PM
I am having trouble opening a RadWindow using server code.  I have to set Session variables before the window is open, so I have to open it in server code.  The server code worked with a regular window, but not with RadWindow.  I have tried all of the techniques listed below (I replaced url with [path] & window name with [name]):

popupScript =

"<script>var wnd = window.radopen(\"[path]\", \"[name]\");</script>";

Page.RegisterStartupScript(

"PopupScript", popupScript);

 


or:
[javascript]

function

 

OpenWindow(name) {

 

 

var wnd = window.radopen([path], [name]);

 

 

wnd.Maximize();

 

return false;

 

}
[c#]

 

popupScript =

"<script>OpenWindow('[name]');</script>";
Page.RegisterStartupScript("PopupScript", popupScript);

or:
popupScript = 'javascript:OpenWindow('[name]');:;
Page.RegisterStartupScript("PopupScript", popupScript);

I know that Page.RegisterStartupScript is considered obsolete, but it still works to open normal windows.  Is there something specific I would have to do to make a RadWindow able to be opened in server code?

 

2 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 29 Jan 2010, 04:59 AM
Hello,

You can open the RadWindow from the server code as shown below.

CS:
 
    protected void Button1_Click(object sender, EventArgs e) 
    { 
        // Your code to set the Session variable 
        RadWindow newwindow = new RadWindow(); // Create new instance of window 
        newwindow.ID = "RadWindow2"
        newwindow.NavigateUrl = "http://www.google.com"; // Set NavigateUrl 
        newwindow.Behaviors = WindowBehaviors.Close; 
        newwindow.VisibleOnPageLoad = true// Set the VisibleOnPageLoad property to True 
        RadWindowManager1.Windows.Add(newwindow); // Adds the window to windowmanager collection 
    } 

Also checkout the following documentation:
Setting Server-Side Properties

-Shinu.
0
Georgi Tunev
Telerik team
answered on 29 Jan 2010, 05:37 AM
Hello M,

I would recommend to follow Shinu's suggestion and open the RadWindow directly from the server using its server-side API.
If for some reason however, you want to keep the client-side approach, I would suggest to check the following blog post:
http://blogs.telerik.com/supportdept/posts/09-05-05/executing_javascript_function_from_server-side_code.aspx

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.
Tags
Window
Asked by
M Oz
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Georgi Tunev
Telerik team
Share this question
or