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
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
Content Page
Dialog Page
Dialog Page server side code Delphi Prism but the one line of code translates easily to C#
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">
<
html
xmlns
=
"http://www.w3.org/1999/xhtml"
>
<
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">
<
html
xmlns
=
"http://www.w3.org/1999/xhtml"
>
<
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.