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

Opening Radwindow on Page load from server side

6 Answers 304 Views
Window
This is a migrated thread and some comments may be shown as answers.
Arima
Top achievements
Rank 1
Arima asked on 07 Sep 2011, 09:00 PM
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);

 


6 Answers, 1 is accepted

Sort by
0
Steve
Top achievements
Rank 2
Veteran
answered on 08 Sep 2011, 02:21 AM
Have you tried just setting the "VisibleOnPageLoad" to true on that window and not bothering with the client script?  Or is the script required?
0
Princy
Top achievements
Rank 1
answered on 08 Sep 2011, 04:37 AM
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.
0
Arima
Top achievements
Rank 1
answered on 08 Sep 2011, 06:54 AM
Hi Princy

I followed that link. I tried same way. I mean added sys.load handler. Still i am getting the same error.
0
Princy
Top achievements
Rank 1
answered on 08 Sep 2011, 07:45 AM
.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.
0
Arima
Top achievements
Rank 1
answered on 08 Sep 2011, 11:57 AM
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.
0
Marin Bratanov
Telerik team
answered on 13 Sep 2011, 09:51 AM
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.
Tags
Window
Asked by
Arima
Top achievements
Rank 1
Answers by
Steve
Top achievements
Rank 2
Veteran
Princy
Top achievements
Rank 1
Arima
Top achievements
Rank 1
Marin Bratanov
Telerik team
Share this question
or