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

Want to pop up window from server side

3 Answers 830 Views
Window
This is a migrated thread and some comments may be shown as answers.
Rakesh
Top achievements
Rank 1
Rakesh asked on 06 Apr 2009, 08:23 PM
Hi All,

I have got a business condition. Depending upon the result i have to show radwindow else do some other thing. I though of adding client side script from server side. The code is somewhat like this

if

 

(test)

 

{

 

String strscript = "<script language='javascript' type='text/javascript'>";

 

strscript +=

"var oWnd = window.radopen('Default2.aspx', 'radwindow');";

 

strscript +=

"</script>";

 

Page.RegisterStartupScript(

"test", strscript);

 

}

But it is not working beacuse of error in javascript. Can any one you help me here please. A demo example would be appreciated

Rakesh

3 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 07 Apr 2009, 06:07 AM
Hello Rakesh,

Try out the following code for showing RadWindow from server side.

ASPX:
 
<telerik:RadWindowManager ID="RadWindowManager1" runat="server">  
<Windows> 
    <telerik:RadWindow runat="server" NavigateUrl="Dialog1.aspx" ID="Window1"></telerik:RadWindow> 
</Windows> 
</telerik:RadWindowManager> 

CS:
 
protected void Button1_Click(object sender, EventArgs e)  
{  
    if (test)  //Condition  
    {  
        string script = "<script language='javascript' type='text/javascript'>Sys.Application.add_load(ShowWindow);</script>";   
        ClientScript.RegisterStartupScript(this.GetType(), "showWindow", script);  
    }  

JavaScript:
<script type="text/javascript">  
function ShowWindow()  
{  
    var oWnd = window.radopen('Default2.aspx''window1');  
}      
</script> 

Otherwise you can simply show the RadWindow from server side since it is possible to configure them dynamically in the code-behind, based on external conditions on the page. See the code snippet shown below.

[ASPX]
 
<telerik:RadWindowManager ID="RadWindowManager1" runat="server">  
</telerik:RadWindowManager>  

[CS]
 
protected void Button4_Click(object sender, EventArgs e)  
{  
    if (test)  
    {  
        RadWindow newWindow = new RadWindow();  
        newWindow.NavigateUrl = "Default2.aspx";  
        newWindow.VisibleOnPageLoad = true;  
        RadWindowManager1.Windows.Add(newWindow);   
    }  

Thanks,
Princy.
0
Georgi Tunev
Telerik team
answered on 07 Apr 2009, 07:00 AM
Hi Rakesh,

Since you are using RadControls for ASP.NET AJAX, you should take into consideration that in MS AJAX environment, all Ajax controls (including ours) are loaded after the page itself is loaded (e.g. after window.onload) in Sys.Application.Load(). You can check this by examining an HTML dump of a page with ASP.NET AJAX controls in it.
That being said, you need to make sure that the controls (in this case RadWindowManager) are loaded on the page before trying to use them. There are different approaches that you could use for that and I suggest you to check this KB - it is for calling radalert() but uses several general approaches that will be of help for your case.


Kind regards,
Georgi Tunev
the Telerik team

Check out Telerik Trainer , the state of the art learning tool for Telerik products.
0
Rahul Khinvasara
Top achievements
Rank 1
answered on 22 Aug 2009, 06:58 AM
Thanks for your help.
Tags
Window
Asked by
Rakesh
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Georgi Tunev
Telerik team
Rahul Khinvasara
Top achievements
Rank 1
Share this question
or