I need to achieve the following scenario:
when the page is loaded, call a client side script, which does something (in this case gather the users location using google api for location) then send that location to the server using ajax manager and ultimately doing a ajax call right after page load.
This all works fine in IE, but its a hit and miss in firefox where the radajaxmanager (most of the time) returns null.
below is the basic setup which is tested in IE8 and firefox 3.6.13 (which where the problem occurs)
also using the trial version of telerik version 2010.3.1215.40
Master
--------
<%@ Master Language="VB" CodeFile="MainMaster.master.vb" Inherits="MainMaster" %>
<!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>
<asp:ContentPlaceHolder ID="head" runat="server">
</asp:ContentPlaceHolder>
</head>
<body>
<form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server" />
<telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
</telerik:RadAjaxManager>
<div>
<asp:ContentPlaceHolder ID="ContentPlaceHolder1" runat="server">
</asp:ContentPlaceHolder>
</div>
</form>
</body>
</html>
Content
----------------------
<%@ Page Title="" Language="VB" MasterPageFile="~/MainMaster.master" AutoEventWireup="false"
CodeFile="Default.aspx.vb" Inherits="_Default" %>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
<telerik:RadCodeBlock ID="RadCodeBlock1" runat="server">
<script type="text/javascript">
function findAjaxManager() {
var m = $find("<%=RadAjaxManager.GetCurrent(Page).ClientID %>");
alert(m);
m.ajaxRequest('Something');
}
</script>
</telerik:RadCodeBlock>
<telerik:RadAjaxManagerProxy ID="RadAjaxManagerProxy1" runat="server">
<AjaxSettings>
<telerik:AjaxSetting AjaxControlID="RadAjaxManager1">
<UpdatedControls>
<telerik:AjaxUpdatedControl ControlID="lblTime" />
</UpdatedControls>
</telerik:AjaxSetting>
</AjaxSettings>
</telerik:RadAjaxManagerProxy>
<asp:Label runat="server" ID="lblTime"></asp:Label>
</asp:Content>
Content Code Behind
------------------------
Imports Telerik.Web.UI
Partial Class _Default
Inherits System.Web.UI.Page
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
AddHandler RadAjaxManager.GetCurrent(Page).AjaxRequest, AddressOf AjaxRequest
If (Not Page.IsPostBack) Then
RadAjaxManager.GetCurrent(Page).ResponseScripts.Add("findAjaxManager();")
End If
End Sub
Private Sub AjaxRequest(ByVal sender As Object, ByVal e As AjaxRequestEventArgs)
If e.Argument = "Something" Then
lblTime.Text = DateTime.Now.ToString
End If
End Sub
End Class
when the page is loaded, call a client side script, which does something (in this case gather the users location using google api for location) then send that location to the server using ajax manager and ultimately doing a ajax call right after page load.
This all works fine in IE, but its a hit and miss in firefox where the radajaxmanager (most of the time) returns null.
below is the basic setup which is tested in IE8 and firefox 3.6.13 (which where the problem occurs)
also using the trial version of telerik version 2010.3.1215.40
Master
--------
<%@ Master Language="VB" CodeFile="MainMaster.master.vb" Inherits="MainMaster" %>
<!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>
<asp:ContentPlaceHolder ID="head" runat="server">
</asp:ContentPlaceHolder>
</head>
<body>
<form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server" />
<telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
</telerik:RadAjaxManager>
<div>
<asp:ContentPlaceHolder ID="ContentPlaceHolder1" runat="server">
</asp:ContentPlaceHolder>
</div>
</form>
</body>
</html>
Content
----------------------
<%@ Page Title="" Language="VB" MasterPageFile="~/MainMaster.master" AutoEventWireup="false"
CodeFile="Default.aspx.vb" Inherits="_Default" %>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
<telerik:RadCodeBlock ID="RadCodeBlock1" runat="server">
<script type="text/javascript">
function findAjaxManager() {
var m = $find("<%=RadAjaxManager.GetCurrent(Page).ClientID %>");
alert(m);
m.ajaxRequest('Something');
}
</script>
</telerik:RadCodeBlock>
<telerik:RadAjaxManagerProxy ID="RadAjaxManagerProxy1" runat="server">
<AjaxSettings>
<telerik:AjaxSetting AjaxControlID="RadAjaxManager1">
<UpdatedControls>
<telerik:AjaxUpdatedControl ControlID="lblTime" />
</UpdatedControls>
</telerik:AjaxSetting>
</AjaxSettings>
</telerik:RadAjaxManagerProxy>
<asp:Label runat="server" ID="lblTime"></asp:Label>
</asp:Content>
Content Code Behind
------------------------
Imports Telerik.Web.UI
Partial Class _Default
Inherits System.Web.UI.Page
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
AddHandler RadAjaxManager.GetCurrent(Page).AjaxRequest, AddressOf AjaxRequest
If (Not Page.IsPostBack) Then
RadAjaxManager.GetCurrent(Page).ResponseScripts.Add("findAjaxManager();")
End If
End Sub
Private Sub AjaxRequest(ByVal sender As Object, ByVal e As AjaxRequestEventArgs)
If e.Argument = "Something" Then
lblTime.Text = DateTime.Now.ToString
End If
End Sub
End Class
10 Answers, 1 is accepted
0
Hello Zoinky,
You can make it work by adding a timeout to your script like this:
Best wishes,
Pavel
the Telerik team
You can make it work by adding a timeout to your script like this:
Copy Code
<telerik:RadCodeBlock ID=
"RadCodeBlock1"
runat=
"server"
>
<script type=
"text/javascript"
>
function
findAjaxManager() {
setTimeout(
function
() {
var
m = $find(
"<%=RadAjaxManager.GetCurrent(Page).ClientID %>"
);
alert(m);
m.ajaxRequest(
'Something'
);
}, 0);
}
</script>
</telerik:RadCodeBlock>
Best wishes,
Pavel
the Telerik team
Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
0
Zoinky
Top achievements
Rank 1
answered on 01 Feb 2011, 03:31 PM
Thanks for the response, I will give that a shot
but just so I advice the client properly, is this something that is a work around to a fix you guys will do or is this pretty much the way to do this for firefox, also If you could elaborate on whats causing this or any other information you can provide on the matter it would be greatly appreciated.
but just so I advice the client properly, is this something that is a work around to a fix you guys will do or is this pretty much the way to do this for firefox, also If you could elaborate on whats causing this or any other information you can provide on the matter it would be greatly appreciated.
0
Hello Zoinky,
The problem is caused by the fact that in this case the client-side object of RadAjaxManager is not fully initialized when the script is executed in FireFox. That is why it can be avoided by adding a timeout for the script.
Best wishes,
Pavel
the Telerik team
The problem is caused by the fact that in this case the client-side object of RadAjaxManager is not fully initialized when the script is executed in FireFox. That is why it can be avoided by adding a timeout for the script.
Best wishes,
Pavel
the Telerik team
Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
0
Joe Sugden
Top achievements
Rank 1
answered on 06 Nov 2012, 07:27 PM
Hello,
Was this a bug, or a limitation due to Firefox's nature?
I just experienced the same problem using the newest version of ASP.NET Ajax controls (2012Q3) and latest version of FF...
Was this ever fixed or I have to always use the solution provided here?
Thanks!
Was this a bug, or a limitation due to Firefox's nature?
I just experienced the same problem using the newest version of ASP.NET Ajax controls (2012Q3) and latest version of FF...
Was this ever fixed or I have to always use the solution provided here?
Thanks!
0
Hello Joe,
As my colleague previous tested this is caused by the fact that in this case the client-side object of RadAjaxManager is not fully initialized when the script is executed in FireFox. Unfortunately this is still valid for the latest version of FF browser and the problem could be only workarounded by adding a TimeOut.
Kind regards,
Maria Ilieva
the Telerik team
As my colleague previous tested this is caused by the fact that in this case the client-side object of RadAjaxManager is not fully initialized when the script is executed in FireFox. Unfortunately this is still valid for the latest version of FF browser and the problem could be only workarounded by adding a TimeOut.
Kind regards,
Maria Ilieva
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
0
Bernard
Top achievements
Rank 1
answered on 19 Feb 2015, 04:54 PM
Hello,
I experimente the same problem with my application BUT ONLY WITH CHROME and FIREFOX
It works fine with IE.
I use Telerik 2014.3.1024.35
The RadScriptManager and the RadAjaxManager are in a MasterPage.
In my content page, I retrieve the RadAjaxManager in a variable in PageLoad() method.
Each ajax call return the RadAjaxManager to null in spite of the "setTimeout"
Thanks for your help...
Bernard
I experimente the same problem with my application BUT ONLY WITH CHROME and FIREFOX
It works fine with IE.
I use Telerik 2014.3.1024.35
The RadScriptManager and the RadAjaxManager are in a MasterPage.
In my content page, I retrieve the RadAjaxManager in a variable in PageLoad() method.
Each ajax call return the RadAjaxManager to null in spite of the "setTimeout"
Thanks for your help...
Bernard
function
pageLoad() {
setTimeout(
function
() {
AY_MP_AjaxManager = $find(
"<%= RadAjaxManager.GetCurrent(Page).ClientID %>"
);
}, 100);
//alert(AY_MP_AjaxManager);
}
<telerik:RadScriptManager
ID
=
"RadScriptManager1"
runat
=
"server"
>
<
Scripts
>
<
asp:ScriptReference
Assembly
=
"Telerik.Web.UI"
Name
=
"Telerik.Web.UI.Common.Core.js"
/>
<
asp:ScriptReference
Assembly
=
"Telerik.Web.UI"
Name
=
"Telerik.Web.UI.Common.jQuery.js"
/>
<
asp:ScriptReference
Assembly
=
"Telerik.Web.UI"
Name
=
"Telerik.Web.UI.Common.jQueryInclude.js"
/>
</
Scripts
>
</
telerik:RadScriptManager
>
<
telerik:RadAjaxManager
ID
=
"RadAjaxManager1"
runat
=
"server"
>
</
telerik:RadAjaxManager
>
0
Hi Bernard,
Find attached a sample test project that presents the correct behavior of this scenario. Test it on your end and see what the difference in your case is.
Regards,
Maria Ilieva
Telerik
Find attached a sample test project that presents the correct behavior of this scenario. Test it on your end and see what the difference in your case is.
Regards,
Maria Ilieva
Telerik
Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.
0
Bernard
Top achievements
Rank 1
answered on 24 Feb 2015, 11:17 AM
Hello Maria,
your simple project worked fine !
So I extracted the code from my project in a simpler project until reproduce the bug.
And then I deleted the code until no bug!
And the culprit is a class in the master page that was commented out.
I do not understand why but it is clear that now it works!
If however, you know the reason, do not hesitate to tell me...
Many thanks for your help.
Regards
Bernard
your simple project worked fine !
So I extracted the code from my project in a simpler project until reproduce the bug.
And then I deleted the code until no bug!
And the culprit is a class in the master page that was commented out.
<style type=
"text/css"
>
/*.panier {
margin: auto;
padding-top: 10px;
display: block;
}*/
</style>
I do not understand why but it is clear that now it works!
If however, you know the reason, do not hesitate to tell me...
Many thanks for your help.
Regards
Bernard
0
Bernard
Top achievements
Rank 1
answered on 24 Feb 2015, 03:37 PM
Hi Maria,
here is a simple projecty which reproduces the problem. With Chrome.
Regards
Bernard
here is a simple projecty which reproduces the problem. With Chrome.
Regards
<%@ Page Title="" Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
<
asp:Content
ID
=
"Content1"
ContentPlaceHolderID
=
"head"
runat
=
"Server"
>
</
asp:Content
>
<
asp:Content
ID
=
"Content2"
ContentPlaceHolderID
=
"ContentPlaceHolder1"
runat
=
"Server"
>
<
telerik:RadScriptBlock
runat
=
"server"
>
<
script
type
=
"text/javascript"
>
function pageLoad() {
AY_MP_AjaxManager = $find("<%= RadAjaxManager.GetCurrent(Page).ClientID %>");
alert(AY_MP_AjaxManager);
}
</
script
>
</
telerik:RadScriptBlock
>
<
asp:Button
ID
=
"Button1"
runat
=
"server"
OnClick
=
"Button1_Click"
Text
=
"Button"
/>
<
asp:Label
ID
=
"Label1"
runat
=
"server"
Text
=
"Label"
></
asp:Label
>
</
asp:Content
>
<%@ Master Language="C#" AutoEventWireup="true" CodeFile="MasterPage.master.cs" Inherits="MasterPage" %>
<!DOCTYPE html>
<
html
xmlns
=
"http://www.w3.org/1999/xhtml"
>
<
head
runat
=
"server"
>
<
title
></
title
>
<
style
type
=
"text/css"
>
/*.panier {
margin: auto;
padding-top: 10px;
display: block;
}*/
</
style
>
<
asp:ContentPlaceHolder
ID
=
"head"
runat
=
"server"
>
</
asp:ContentPlaceHolder
>
</
head
>
<
body
>
<
form
id
=
"form1"
runat
=
"server"
>
<
div
>
<
telerik:RadScriptManager
ID
=
"RadScriptManager1"
runat
=
"server"
>
<
Scripts
>
<
asp:ScriptReference
Assembly
=
"Telerik.Web.UI"
Name
=
"Telerik.Web.UI.Common.Core.js"
/>
<
asp:ScriptReference
Assembly
=
"Telerik.Web.UI"
Name
=
"Telerik.Web.UI.Common.jQuery.js"
/>
<
asp:ScriptReference
Assembly
=
"Telerik.Web.UI"
Name
=
"Telerik.Web.UI.Common.jQueryInclude.js"
/>
</
Scripts
>
</
telerik:RadScriptManager
>
<
telerik:RadAjaxManager
ID
=
"RadAjaxManager1"
runat
=
"server"
>
</
telerik:RadAjaxManager
>
<
asp:ContentPlaceHolder
ID
=
"ContentPlaceHolder1"
runat
=
"server"
>
</
asp:ContentPlaceHolder
>
</
div
>
</
form
>
</
body
>
</
html
>
using
System;
using
System.Collections.Generic;
using
System.Linq;
using
System.Web;
using
System.Web.UI;
using
System.Web.UI.WebControls;
using
Telerik.Web.UI;
public
partial
class
_Default : System.Web.UI.Page
{
private
Label aLabel;
private
Button aButton;
protected
void
Page_Load(
object
sender, EventArgs e)
{
ContentPlaceHolder aContentPlaceHolder = (ContentPlaceHolder)Master.FindControl(@
"ContentPlaceHolder1"
);
aButton = (Button)aContentPlaceHolder.FindControl(@
"Button1"
);
aLabel = (Label)aContentPlaceHolder.FindControl(@
"Label1"
);
RadAjaxManager.GetCurrent(
this
).AjaxSettings.AddAjaxSetting(aButton, aLabel);
}
protected
void
Button1_Click(
object
sender, EventArgs e)
{
aLabel.Text =
"Ajax Call - "
+ DateTime.Now.ToString();
}
}
using
System;
using
System.Collections.Generic;
using
System.Linq;
using
System.Web;
using
System.Web.UI;
using
System.Web.UI.WebControls;
public
partial
class
MasterPage : System.Web.UI.MasterPage
{
protected
void
Page_Load(
object
sender, EventArgs e)
{
}
}
Bernard
0
Hi Bernard,
Your findings are correct and the issue is indeed related to your commented CSS.
Due to the way that RadAjaxManager is implemented, having commented lines in the CSS with that syntax will break its functionality.
If you want to have CSS comments you could use an external file with your styles and remove your CSS from the page.
Hope this helps.
Regards,
Konstantin Dikov
Telerik
Your findings are correct and the issue is indeed related to your commented CSS.
Due to the way that RadAjaxManager is implemented, having commented lines in the CSS with that syntax will break its functionality.
If you want to have CSS comments you could use an external file with your styles and remove your CSS from the page.
Hope this helps.
Regards,
Konstantin Dikov
Telerik
Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.