RadAjaxManager in Page Template
How do I add a RadAjaxManager to a SiteFinity template. Do I have to create a physical masterpage file and add it there, or can it be done without adding my own masterpage file? I would like for the RadAjaxManager to be available to my custom user control.
Hello John Hunter,
Thank you for using our services.
Currently there is only one way you can work with the RadAjaxManager control. You have to create a physical master page from which you will create a template. In the code file of this master page you have to override the OnInit method and add the AjaxManager if the page is not in edit mode. Sample markup bellow:
<%@ Master Language=
"C#"
AutoEventWireup=
"true"
CodeBehind=
"AjaxMaster.master.cs"
Inherits=
"SitefinityWebApp.App_Master.AjaxMaster"
%>
<!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>
</head>
<body>
<form id=
"form1"
runat=
"server"
>
<telerik:RadScriptManager runat=
"server"
ID=
"ScriptManager1"
></telerik:RadScriptManager>
<div>
<asp:ContentPlaceHolder ID=
"ContentPlaceHolder1"
runat=
"server"
>
</asp:ContentPlaceHolder>
</div>
</form>
</body>
</html>
protected
override
void
OnInit(EventArgs e)
base
.OnInit(e);
if
(!
this
.IsDesignMode())
RadAjaxManager ajaxManager =
new
RadAjaxManager();
//get the index of the script manager and add the ajax manager right after it
int
index =
this
.form1.Controls.IndexOf(ScriptManager1);
this
.form1.Controls.AddAt(index + 1, ajaxManager);
<
telerik:RadAjaxManagerProxy
runat
=
"server"
ID
=
"ManagerProxy1"
>
<
AjaxSettings
>
<
telerik:AjaxSetting
AjaxControlID
=
"Panel1"
>
<
UpdatedControls
>
<
telerik:AjaxUpdatedControl
ControlID
=
"Panel1"
LoadingPanelID
=
"RadAjaxLoadingPanel1"
/>
</
UpdatedControls
>
</
telerik:AjaxSetting
>
</
AjaxSettings
>
</
telerik:RadAjaxManagerProxy
>
<
asp:Panel
ID
=
"Panel1"
runat
=
"server"
HorizontalAlign
=
"Center"
Height
=
"275px"
>
<
asp:Button
ID
=
"Button1"
runat
=
"server"
Text
=
"Click to see the loading image"
OnClick
=
"Button1_Click"
Style
=
"margin-top: 15px; margin-left: 15px"
CssClass
=
"qsfButtonBigger"
/>
</
asp:Panel
>
<
telerik:RadAjaxLoadingPanel
ID
=
"RadAjaxLoadingPanel1"
runat
=
"server"
Skin
=
"Telerik"
>
</
telerik:RadAjaxLoadingPanel
>
public
void
Button1_Click(
object
sender, EventArgs e)
//simulate longer page load
System.Threading.Thread.Sleep(2000);
protected
override
void
OnInit(EventArgs e)
base
.OnInit(e);
if
(!
this
.IsDesignMode())
RadAjaxManager ajaxManager = RadAjaxManager.GetCurrent(
this
.Page);
if
(ajaxManager !=
null
)
ajaxManager.AjaxSettings.AddAjaxSetting(Panel1, Panel1, RadAjaxLoadingPanel1);
Hi,
I tried to create the master page with your code and than the user control with RadAjaxManagerProxy but it didn't work...What I wrong?
Hello Stefano,
Actually, we have used this sample form our ASP.NET Ajax Demos to isolate the provided example, do you mind taking a look at it and let us know whether following the steps described in the demo works for you? Looking forwards to your reply.
Best wishes,
Boyan Barnev
the Telerik team
It is possible that with the trial versione of sitefinity ajax didn't work?
your code is very helpfull for me if you have any other plz alwayes share with me i'm too much intersed to it........
thank for your sharing..........
Hi Stefano,
Can you please check whether you have EnableViewstate property checked from the page's title and properties, there should be no problems running Ajax controls with the trial version.
Best wishes,
Boyan Barnev
the Telerik team
Stafano,
Your "ajax" doesn't work because RadAjaxPanel does NOT work (as expected) in Sitefinity 4.x. I have found it to do NOTHING. I have been going around and around on this topic (in other forum posts and service tickets). Telerik confirmed for me that it in fact does NOT work inside SF. (Yes, it works in a normal website outside SF).
You can get around it a little by using some other container (like ASP:PANEL) and then wire that up through RadAjaxManagerProxy for your AJAX. RadAjaxManager (and proxy) DOES produce AJAX results.
That is of course if you are NOT using a master page as a template. I am getting GOOD AJAX results (from user controls...created from an external assembly) as long as I use a BLANK template (i.e. NOT from a master page).
The minute I try to put that same User Control that works with partial post-back AJAX results on a BLANK template onto a template (with pretty much nothing on it) created from a MASTER PAGE, my user control produces FULL post-backs when it shouldn't (and doesn't on the BLANK template).
I don't know what is going on with that part... been dealing with it for a week now and going back and forth with Telerik on it.
Hi Shawn Krivjansky,
Indeed there is certainWe have explained the reasons behind the problemqatic behavior in the support thread you have opened. For Stefano's and the other community members who might be interested I'm pasting our reply below:
"The RadAjaxPanel has a problem. It tries to look for a script manager too early in the page life cycle. Unless the script manager is added to a master page's markup, the RadAjaxPanel is not properly initialized. The problem is the same as the one described in this blog post."
@Stefano, can you please try the solution outlined in the blogpost and let us know if any problems persist?
Regards,
Boyan Barnev
the Telerik team
Thank you for being the most amazing .NET community! Your unfailing support is what helps us charge forward! We'd appreciate your vote for Telerik in this year's DevProConnections Awards. We are competing in mind-blowing 20 categories and every vote counts! VOTE for Telerik NOW >>