Want to pop up window from server side

4 posts, 0 answers
  1. Rakesh
    Rakesh avatar
    2 posts
    Member since:
    Apr 2009

    Posted 06 Apr 2009 Link to this post

    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

  2. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 07 Apr 2009 Link to this post

    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.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Georgi Tunev
    Admin
    Georgi Tunev avatar
    7207 posts

    Posted 07 Apr 2009 Link to this post

    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.
  5. Rahul Khinvasara
    Rahul Khinvasara avatar
    303 posts
    Member since:
    Aug 2007

    Posted 22 Aug 2009 Link to this post

    Thanks for your help.
Back to Top