RadAjaxManager in Page Template

Posted by Community Admin on 03-Aug-2018 03:15

RadAjaxManager in Page Template

All Replies

Posted by Community Admin on 23-Nov-2010 00:00

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.

Posted by Community Admin on 24-Nov-2010 00:00

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">
 
<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>

code:
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);
    

Then you can use RadAjaxManagerProxy in your user control or directly get a reference of the control and set the Ajax settings:
<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>

code:
public void Button1_Click(object sender, EventArgs e)
    //simulate longer page load
    System.Threading.Thread.Sleep(2000);

You can also create AjaxSettings using code instead of using the proxy manager (done using OnInit event of the user control):
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);
        
    

Sincerely yours,
Radoslav Georgiev
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items

Posted by Community Admin on 05-Jul-2011 00:00

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?

Posted by Community Admin on 08-Jul-2011 00:00

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

Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items

Posted by Community Admin on 12-Jul-2011 00:00

I attach my Code of Custom User Control and of my master Page. My ajaxPanel didn't work...What can I do?

Posted by Community Admin on 14-Jul-2011 00:00

It is possible that with the trial versione of sitefinity ajax didn't work?

Posted by Community Admin on 30-Jul-2011 00:00

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..........

Foam in Place

Posted by Community Admin on 02-Aug-2011 00:00

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

Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items

Posted by Community Admin on 01-Sep-2011 00:00

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.

Posted by Community Admin on 03-Sep-2011 00:00

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 >>

This thread is closed