Dynamically open a radwindow defined in Javascript

3 posts, 0 answers
  1. Xorv
    Xorv avatar
    19 posts
    Member since:
    Jan 2012

    Posted 07 Oct 2012 Link to this post

    Hi guys,

    Objective:- From the server-side, I need to open a radwindow(defined in javascipt of the aspx page) automatically on an IF condition.

    In aspx page, I defined the radwindow as:-
    <telerik:RadWindowManager Skin="WBDA" ID="AssetPreviewManager" Modal="true" 
    EnableEmbeddedSkins="false" runat="server"  DestroyOnClose="true" Behavior="Close" 
    style="z-index:8000"
         <Windows>  
         <telerik:RadWindow ID="DisclaimerAlertWindow" runat="server" Width="720px" Height="220px" 
    Modal="true" visibleStatusbar="false" VisibleTitlebar="false" keepInScreenBounds="true" title="Sourav">                                           
         </telerik:RadWindow
         </Windows
         </telerik:RadWindowManager>

    In Javascript, a fucntion is defined for opening the radwindow:-
    function openRadWindow()
         {
            var oWnd = radopen('DisclaimerAlert.aspx, 'DisclaimerAlertWindow');
            oWnd.set_title('Access Denied !'); 
            oWnd.Center();
            return false;
         }

    So on the server side of the aspx page, In the Page Load event an IF condition is checked and then I'm calling 'openRadWindow()' function as:-
    protected void Page_Load(object sender, EventArgs e)

    {

    if (fieldValue == "False")
    {
     string xyz = "<script type='text/javascript' lang='Javascript'>myFunction();</script>";
     ClientScript.RegisterStartupScript(this.GetType(), "Window", xyz);
    }
    }

    But on running this, these Javascript errors are coming:-

    1. Object doesn't support this property or method.
    2. 'undefined' is null or not an object



    Please help how to achieve my objective. I am totally stuck.
  2. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 07 Oct 2012 Link to this post

    Hi Xorv,

    Try the following code snippet in the Page_Load function.

    C#:
    protected void Page_Load(object sender, EventArgs e)
      {
        if (fieldValue == "False")
          {
             string script = "<script language='javascript'>function f(){openRadWindow(); Sys.Application.remove_load(f);}; Sys.Application.add_load(f);</script>";
             Page.ClientScript.RegisterStartupScript(this.GetType(), "Window", script);
          }
      }

    Hope this helps.

    Regards,
    Shinu.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. <span>w</span>
    <span>w</span> avatar
    84 posts
    Member since:
    Jun 2012

    Posted 13 Oct 2012 Link to this post

    My Dear use this for open Radwindow for specific condition in IF.

    bool Check=true;
    protected void Page_Load(object sender, EventArgs e)
    {
     if(Check==true)
     {
     string script = "function f(){ var oWnd = $find(\"" + PrintWindow.ClientID + "\"); oWnd.setUrl('Testing.aspx'); oWnd.show();       Sys.Application.remove_load(f);}Sys.Application.add_load(f);";
     ScriptManager.RegisterStartupScript(Page, Page.GetType(), "key", script, true);
     }
    }

    Regards
    Muhammad Waseem
Back to Top