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

GetRadWindow returns undefined on first attempt with FireFox

3 Answers 192 Views
Window
This is a migrated thread and some comments may be shown as answers.
Raymond Andrews
Top achievements
Rank 1
Raymond Andrews asked on 14 Oct 2010, 05:43 PM
I've been beating my head against the desk for the better part of a week trying to find out why my program would not call a javascript function from an ajax postback.  I tracked the problem down to GetRadWindow not returning a window.  Searching the forums found a couple other examples of people with a similar odd problems with no solutions as yet.  The good Telerik folks have tried their best to help me in other forum posts. but this one I fear may be a Firefox issue.

Telerik 2010.1.519.35 - FireFox 3.6

  • I have a master page which has a javascript function I want to call. 
  • From the content page I open a radwindow which is defined in the radwindowmanager of the master page. 
  • When a button in the radwindow is clicked I want to registerstartupscript so I can call the javascript function in the main page.

This does not work the first time the radwindow is opened, but only in FireFox

If I click the button that opens the radwindow, and then click the button in the radwindow to make the call, it fails, not having gotten a valid radwindow from GetRadWindow.  I can click the button multiple times, it still does not work.  If I close the radwindow, and click the button to open the radwindow again, the second (and subsequent) times if functions as it should.

If I execute the same code from Internet Explorer it functions properly every time.  It's as if Firefox doesn't add the radwindow to it's internal list of windows until after it's been closed (just a guess)

A simpler example with just a webpage and radwindow had no problems, only the combination of master page, content page, and radwindow exhibited the problem for me

live example at  http://www.steeltoad.com/ajaxdialogtest
full source at  http://www.steeltoad.com/ajaxdialogtest2.zip


MasterPage
<%@ Master Language="Oxygene" AutoEventWireup="true" CodeBehind="MasterPage.master.pas" Inherits="AjaxDialogTest2.MasterPage" %>
<%@ Register assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" namespace="System.Web.UI" tagprefix="asp" %>
<%@ Register assembly="Telerik.Web.UI, Version=2010.1.519.35, Culture=neutral, PublicKeyToken=121fae78165ba3d4" namespace="Telerik.Web.UI" tagprefix="telerik" %>
 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 
<head runat="server">
    <title></title>
     
    <script language="javascript" type="text/javascript">
      function MasterPageTest(arg)
        { alert('Master Page : '+arg); }
    </script>
     
    <asp:ContentPlaceHolder ID="head" runat="server">
    </asp:ContentPlaceHolder>
</head>
 
<body>
  <form id="form1" runat="server">
 
  <telerik:RadScriptManager ID="RadScriptManager1" Runat="server">
  </telerik:RadScriptManager>
 
  <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
  </telerik:RadAjaxManager>
       
    <telerik:RadWindowManager ID="RadWindowManager1" runat="server"
      Skin="Sunset" ShowContentDuringLoad="False" VisibleStatusbar="False"
      KeepInScreenBounds="True" EnableViewState="False"
      Behavior="Close, Move" Behaviors="Close, Move"
      InitialBehavior="Resize, Close, Move" InitialBehaviors="Resize, Close, Move" ReloadOnShow="True">
      <Windows>
        <telerik:RadWindow ID="wDialog" runat="server"
          NavigateUrl="DialogForm.aspx" Title="Dialog Form"
          Height="345px" Width="540px" >
        </telerik:RadWindow>
      </Windows>
    </telerik:RadWindowManager>
 
    <div>
      <asp:ContentPlaceHolder ID="ContentPlaceHolder1" runat="server">
      </asp:ContentPlaceHolder>
    </div>
 
  </form>
</body>
</html>

Content Page
<%@ Page Title="" Language="Oxygene" MasterPageFile="~/MasterPage.Master" AutoEventWireup="true" CodeBehind="ContentPage.aspx.pas" Inherits="AjaxDialogTest2.ContentPage" %>
<%@ Register assembly="Telerik.Web.UI, Version=2010.1.519.35, Culture=neutral, PublicKeyToken=121fae78165ba3d4" namespace="Telerik.Web.UI" tagprefix="telerik" %>
 
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
</asp:Content>
 
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
 
    <script language="javascript" type="text/javascript">
      function ShowDialogForm(id)
        {
        var oWnd = window.radopen("DialogForm.aspx","wDialog");
        oWnd.SetTitle("Dialog Form");
        return false;
        }
    </script>
 
    <asp:Button ID="Button1" runat="server" Text="Open Dialog" onclientclick="ShowDialogForm(); return false;" />
  
</asp:Content>

Dialog Page
<%@ Page Language="Oxygene" AutoEventWireup="true" CodeBehind="DialogForm.aspx.pas" Inherits="AjaxDialogTest.DialogForm" %>
<%@ Register assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" namespace="System.Web.UI" tagprefix="asp" %>
<%@ Register assembly="Telerik.Web.UI, Version=2010.1.519.35, Culture=neutral, PublicKeyToken=121fae78165ba3d4" namespace="Telerik.Web.UI" tagprefix="telerik" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 
<head runat="server">
<title>Untitled Page</title>
 
    <script language="javascript" type="text/javascript">
      function GetRadWindow()
        {
        var oWindow = null;
        if (window.radWindow)
          { oWindow = window.RadWindow; }   
        else if (window.frameElement.radWindow)
          { oWindow = window.frameElement.radWindow; }     
        return oWindow;
        }
 
      function DialogCommand(arg)
        
        var rw = GetRadWindow();
        alert('About to call MasterPageTest');
        rw.BrowserWindow.MasterPageTest(arg);
        alert('Called MasterPageTest');
        }
    </script>   
     
</head>
<body>
    <form id="form1" runat="server">
    <div>
     
      <telerik:RadScriptManager ID="RadScriptManager1" Runat="server">
      </telerik:RadScriptManager>
     
      <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
        <AjaxSettings>
          <telerik:AjaxSetting AjaxControlID="AjaxButton">
            <UpdatedControls>
              <telerik:AjaxUpdatedControl ControlID="AjaxButton" />
            </UpdatedControls>
          </telerik:AjaxSetting>
        </AjaxSettings>
      </telerik:RadAjaxManager>
      <asp:Button ID="AjaxButton" runat="server" Text="Test" onclick="ButtonClicked" />
 
    </div>
    </form>
</body>
</html>


Dialog Page server side code    Delphi Prism but the one line of code translates easily to C#
namespace AjaxDialogTest;
 
interface
 
uses
  Telerik.Web.UI,
  System,
  System.Data,
  System.Configuration,
  System.Linq,
  System.Web,
  System.Web.Security,
  System.Web.SessionState,
  System.Web.UI,
  System.Web.UI.WebControls,
  System.Web.UI.WebControls.WebParts,
  System.Web.UI.HtmlControls;
 
type
  DialogForm = public partial class(System.Web.UI.Page)
  protected
    method ButtonClicked(sender: System.Object; e: System.EventArgs);
    method Page_Load(sender: Object; e: EventArgs);
  end;
 
implementation
 
method DialogForm.Page_Load(sender: Object; e: EventArgs);
begin
end;
 
 
method DialogForm.ButtonClicked(sender: System.Object; e: System.EventArgs);
begin
  RadScriptManager.RegisterStartupScript(self,GetType(),"addScript","DialogCommand('Test');",true);
end;
 
 
end.

3 Answers, 1 is accepted

Sort by
0
Accepted
Cori
Top achievements
Rank 2
answered on 14 Oct 2010, 06:26 PM

Hello Raymond,

I don't know if the issue is in your first check in the GetRadWindow method where you write RadWindow, instead of radWindow. Other than that, I think if your using the RadAjaxManager control you can pass the DialogCommand call in the ResponseScripts collection of the RadAjaxManager.

 

I hope that helps.

0
Raymond Andrews
Top achievements
Rank 1
answered on 14 Oct 2010, 06:56 PM
HOW did I miss that ?  Thank you,

It still puzzles me as to why it wouldn't work the first time, but would on later attempts or why just with Firefox, but I guess the answer is to do things the right way in the first place.  With that change it seems to work correctly.

Thanks Again

Moderators :  Feel free to delete this post if you think it will lead somebody off in the wrong direction
0
Tobias
Top achievements
Rank 1
answered on 03 Nov 2011, 12:57 PM
Hi!
I also just spent several hours looking for this solution, double checking every line. Please don't delete the thread - I'm sure I copied the GetRadWindow() function from one of the original Telerik examples, it has the RadWindow vs. radWindow mistake in it! I'll post the exact page if I find it again.

Tobias
Tags
Window
Asked by
Raymond Andrews
Top achievements
Rank 1
Answers by
Cori
Top achievements
Rank 2
Raymond Andrews
Top achievements
Rank 1
Tobias
Top achievements
Rank 1
Share this question
or