Opening Radwindow on Page load from server side

7 posts, 0 answers
  1. Arima
    Arima avatar
    25 posts
    Member since:
    Mar 2011

    Posted 07 Sep 2011 Link to this post

    Hi

    I am getting error " microsoft jscript runtime error 'undefined' is null or not an object" when i call clent script code from code behind in page load event. ( I shoul open the radwindow on page load).  Please see my code below.

    ASPX Code
    <%@ Page Language="C#" MasterPageFile="~/CMMasterPage.master" AutoEventWireup="true"
        CodeFile="ActualvsRequired.aspx.cs" Inherits="Reports_ActualvsRequired" Title="Untitled Page" %>
      
    <%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>
    <%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Charting" TagPrefix="telerik" %>
    <asp:Content ID="Content2" ContentPlaceHolderID="header" runat="Server">
        Resource Level
    </asp:Content>
    <asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
        <link href="../Styles/CrewMetric_StyleSheet.css" rel="stylesheet" type="text/css" />
        <script language="javascript" type="text/javascript">
            //Sys.Application.remove_load(RadWindowOpen);
            //Sys.Application.add_load(RadWindowOpen);
            var oWnd;
      
            function RadWindowOpen() {
      
                    if (oWnd != null) {
                        oWnd.close();
                    }
                    oWnd = radopen("GridDisplay.aspx", null); ///Getting error
                    oWnd.setSize(200, 225);
                    oWnd.moveTo(1090, 160);
                    return false;
                }
        </script>
          
         
        <div id="divContentPage" class="subbody" runat="server">
            <div style="float: left; margin-left: 8px; margin-top: 10px;">
                <telerik:RadChart runat="Server" ID="RadChartAvR" Width="900px" Height="560" OnItemDataBound="RadChartAvR_ItemDataBound"
                    OnBeforeLayout="RadChartAvR_BeforeLayout">
                    <PlotArea>
                        <EmptySeriesMessage Visible="True">
                            <Appearance Visible="True">
                            </Appearance>
                        </EmptySeriesMessage>
                        <YAxis>
                            <AxisLabel Visible="true" TextBlock-Text="% of Actual Deviation from Requirement">
                                <Appearance Visible="True">
                                </Appearance>
                                <TextBlock Text="% of Actual Deviation from Requirement">
                                </TextBlock>
                            </AxisLabel>
                        </YAxis>
                    </PlotArea>
                    <ChartTitle Visible="true">
                          
                    </ChartTitle>
                </telerik:RadChart>
            </div>
            <div style="clear: both">
            </div>
        </div>
        <div>
            <asp:HiddenField ID="hiddenCrewType" runat="server" />
        </div>
        <telerik:RadWindowManager ID="RadWindowManager2" runat="server" ReloadOnShow="false" Skin="Sunset" BackColor="DodgerBlue" EnableEmbeddedSkins="false"
            ShowContentDuringLoad="False" VisibleStatusbar="False"  InitialBehavior="None" Behaviors="Move" 
            Font-Names="Tahoma" VisibleOnPageLoad="false" Style="z-index: 8000;" EnableShadow="true"
            DestroyOnClose="True">
        </telerik:RadWindowManager>
    </asp:Content>


    CS Code:

    ScriptManager

     

     

    .RegisterStartupScript(this.Page, Page.GetType(), "test", "RadWindowOpen();", true);

     


  2. Steve
    Steve avatar
    1885 posts
    Member since:
    Dec 2008

    Posted 07 Sep 2011 Link to this post

    Have you tried just setting the "VisibleOnPageLoad" to true on that window and not bothering with the client script?  Or is the script required?
  3. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 07 Sep 2011 Link to this post

    Hello Arima,

    RadControls for ASP.NET AJAX, being MS AJAX objects, are rendered after page is loaded (e.g. after window.onload is fired). Therefore executing code in the window.onload event doesn't ensure that the RadWindowManager is already rendered on the page and you need to add a Sys.Application.Load handler.

    You can find more information on this for here.

    Thanks,
    Princy.
  4. Arima
    Arima avatar
    25 posts
    Member since:
    Mar 2011

    Posted 08 Sep 2011 Link to this post

    Hi Princy

    I followed that link. I tried same way. I mean added sys.load handler. Still i am getting the same error.
  5. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 08 Sep 2011 Link to this post

    .Hello Arima,
    I have tried the scenario and worked as expected at my end. Here is the full code.
    aspx:
    <head runat="server">
      <script language="javascript" type="text/javascript">
        var oWnd;
        function RadWindowOpen()
         {
          if (oWnd != null)
          {
           oWnd.close();
          }
          oWnd = radopen("GridDisplay.aspx", null); ///Getting error
          oWnd.setSize(200, 225);
          oWnd.moveTo(1090, 160);
          return false;
         }
        </script>
    </head>
    <body>
     <form id="form1" runat="server">
      <div>
        <asp:ScriptManager ID="Scriptmanager1" runat="server">
        </asp:ScriptManager>
        <telerik:RadWindowManager ID="RadWindowManager2" runat="server" ReloadOnShow="false" Skin="Sunset" BackColor="DodgerBlue" EnableEmbeddedSkins="false" ShowContentDuringLoad="False" VisibleStatusbar="False" InitialBehavior="None" Behaviors="Move" Font-Names="Tahoma" VisibleOnPageLoad="false" Style="z-index: 8000;" EnableShadow="true" DestroyOnClose="True">
        </telerik:RadWindowManager>
      </div>
     </form>
    </body>
    C#:
    protected void Page_Load(object sender, EventArgs e)
    {
     string openWindowScript = "<script language='javascript'>function f(){RadWindowOpen(); Sys.Application.remove_load(f);}; Sys.Application.add_load(f);</script>";
     Page.ClientScript.RegisterStartupScript(this.GetType(), "radalert", openWindowScript); 
    }

    Hope it helps.

    Thanks,
    Princy.
  6. Arima
    Arima avatar
    25 posts
    Member since:
    Mar 2011

    Posted 08 Sep 2011 Link to this post

    Hi Princy

    Thanks for your help. Now radwindow is opening only once on page load.  I mean i have two tab button ( tab1 and tab2) on my master page. Lets say i have home.aspx. On top of the page, i am displaying two tab button. On each tab click, event i am redirecting to the same page(Home.aspx). This is what my requirement. What is happening now, by default, i selected tab1. on page load rad window is opening. When i click on tab2, i am actually redireting to the same page. this time radwindow is not opening. Is there any setting? I have tried putting VisibleOnPageLoad = true also.
  7. Marin Bratanov
    Admin
    Marin Bratanov avatar
    4569 posts

    Posted 13 Sep 2011 Link to this post

    Hi Arima,

    Please refer to your other thread on the matter for more information on the subject: http://www.telerik.com/community/forums/aspnet-ajax/window/setting-position-for-radwindow-from-serverside.aspx.

    I kindly ask you to post only one thread for a single matter in the future, as it would speed up responses and would ease the tracking of the issue.


    Kind regards,
    Marin
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Back to Top