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

RadAjax Loading panel is not showing up in MOSS

4 Answers 86 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Ronak
Top achievements
Rank 1
Ronak asked on 30 Jan 2012, 04:25 PM
Hi,
i am creating user control webpart which use radscheduler and loading Panel but its not showing up.
please advise what i am doing wrong.
i can send you code but i am not able to.
Thanks
Ronak

4 Answers, 1 is accepted

Sort by
0
Maria Ilieva
Telerik team
answered on 02 Feb 2012, 09:46 AM
Hi Ronak,

Thank you for contacting us.

Please ensure that you have added the AjaxManager and it settings correctly.Ajaxifying the telerik controls that are positioned within a user controls works somewhat differently from the scenario when they are loaded directly on a web form. In you case, you need to move the RadAjaxManager control to the web part class, create it there and add it to the Controls collection of the web part as follows:
private RadAjaxManager _ajaxManager;
 
protected override void OnInit(EventArgs e)
{
    base.OnInit(e);
    SetUpAjaxManagerOnPage();
    EnsureChildControls();
}
protected void SetUpAjaxManagerOnPage()
  
{
    RadAjaxManager currentAjaxManager = RadAjaxManager.GetCurrent(Page);
  
    if (currentAjaxManager == null)
    {
        Page.Form.Controls.AddAt(0, AjaxManager);
        Page.Items.Add(typeof(RadAjaxManager), AjaxManager);
    }
}
protected virtual RadAjaxManager AjaxManager
{
    get
  
    {
        if (_ajaxManager == null)
  
        {
            _ajaxManager = RadAjaxManager.GetCurrent(Page);
            if (_ajaxManager == null)
            {
                _ajaxManager = new RadAjaxManager() { ID = "RadAjaxManager1" };
            }
  
        }
        return _ajaxManager;
    }
}

Then in the OnLoad event of the web part, get the RadAjaxManager as follows:
RadAjaxManager _manager = RadAjaxManager.GetCurrent(Page);

and add your ajax settings programmatically and add the LoadingPanel to those settings. Beforehand, you should have the user control in the CreateChildControls method of the web part and there through FindControl you should retrieve the controls to ajaxify. Keep them in a private variable local to the web part class and use that in the OnLoad event to dynamically add the ajax settings.

Also please ensure that your RadAjaxLoadingPanel have "Skin" property set.

Hope this information will prove helpful.

Greetings,
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
Ronak
Top achievements
Rank 1
answered on 09 Feb 2012, 04:16 PM
Thanks Maria for your reply.I have done that here is code
public class HelloTelerikWebPartWebPart : WebPart {
     
    private const string ASCX_PATH = @"~/_CONTROLTEMPLATES/WSPBuilderProject1/HelloTelerikWebPartUserControl.ascx";
    private bool _error = false;
     
    public HelloTelerikWebPartWebPart() {
    }
    RadAjaxManager ajaxManager;
    protected override void OnInit(EventArgs e) {
        base.OnInit(e);
        Page.ClientScript.RegisterStartupScript(typeof(HelloTelerikWebPartWebPart), this.ID, "_spOriginalFormAction = document.forms[0].action;_spSuppressFormOnSubmitWrapper=true;", true);
        if (this.Page.Form != null) {
            string formOnSubmitAtt = this.Page.Form.Attributes["onsubmit"];
            if (!string.IsNullOrEmpty(formOnSubmitAtt) && formOnSubmitAtt == "return _spFormOnSubmitWrapper();") {
                this.Page.Form.Attributes["onsubmit"] = "_spFormOnSubmitWrapper();";
            }
        }
        ajaxManager = new RadAjaxManager();
        Page.Items.Add(typeof(RadAjaxManager), ajaxManager);
        Page.Form.Controls.AddAt(0, ajaxManager);
 
    }
    /// <summary>
    /// Create all your controls here for rendering.
    /// Try to avoid using the RenderWebPart() method.
    /// </summary>
    protected override void CreateChildControls()
    {
        if (!_error) {
            try  {
 
                base.CreateChildControls();
                Control control = this.Page.LoadControl(ASCX_PATH);
                Controls.Add(control);
                Panel panel = control.FindControl("ListViewPanel1") as Panel;
                RadAjaxLoadingPanel loadingPanel = control.FindControl("RadAjaxLoadingPanel1") as RadAjaxLoadingPanel;
                ajaxManager.AjaxSettings.AddAjaxSetting(panel, panel,loadingPanel);
                 
            }
            catch (Exception ex) {
                HandleException(ex);
            }
        }
    }
 
Here is code in UserControl.ascx
<Telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" runat="server" Skin="default"></Telerik:RadAjaxLoadingPanel>
<asp:Panel ID="ListViewPanel1" runat="server">
    <div>
        <Telerik:RadScheduler runat="server" ID="RadScheduler1"
                              DayStartTime="08:00:00"
                              DayEndTime="18:00:00"
                              TimeZoneOffset="03:00:00"
                              ReadOnly="true"
                              DataKeyField="ID"
                              DataSubjectField="Subject"
                              DataStartField="Start"
                              DataEndField="End"
                              DataRecurrenceField="RecurrenceRule"
                              DataRecurrenceParentKeyField="RecurrenceParentId"
                              DataReminderField="Reminder">
            <TimelineView UserSelectable="false" />
            <TimeSlotContextMenuSettings EnableDefault="true" />
            <AppointmentContextMenuSettings EnableDefault="true" />
             
        </Telerik:RadScheduler>
    </div>
</asp:Panel>

Usercontol.ascx.cs

using System;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using Telerik.Web.UI;
using System.Collections.Generic;
 
namespace WSPBuilderProject1.UI
{
    public partial class HelloTelerikWebPartUserControl : UserControl
    {
        protected void Page_Load(object sender, EventArgs e) {
            
        }
        /*protected void OnNodeClick(object sender, RadTreeNodeEventArgs e) {
            lblMsg.Text = DateTime.Now.ToLongTimeString();
        } */
        private const string AppointmentsKey = "Telerik.Web.Examples.Scheduler.BindToList.CS.Apts";
        List<AppointmentInfo> sessApts = null;
         
        protected override void OnInit(EventArgs e)
        {
            base.OnInit(e);
 
            if (!IsPostBack)
            {
                //Session.Remove(AppointmentsKey);
 
                InitializeResources();
                InitializeAppointments();
            }
           RadScheduler1.DataSource = sessApts;
        }
        private void InitializeResources()
        {
            ResourceType resType = new ResourceType("User");
            resType.ForeignKeyField = "UserID";
 
            RadScheduler1.ResourceTypes.Add(resType);
            RadScheduler1.Resources.Add(new Resource("User", 1, "Alex"));
            RadScheduler1.Resources.Add(new Resource("User", 2, "Bob"));
            RadScheduler1.Resources.Add(new Resource("User", 3, "Charlie"));
        }
 
        private void InitializeAppointments()
        {
            sessApts = new List<AppointmentInfo>();
            DateTime start = DateTime.UtcNow.Date;
            start = start.AddHours(6);
            sessApts.Add(new AppointmentInfo("Take the car to the service", start, start.AddHours(1), string.Empty, null, string.Empty,1));
            sessApts.Add(new AppointmentInfo("Meeting with Alex", start.AddHours(2), start.AddHours(3), string.Empty, null, string.Empty, 2));
 
            start = start.AddDays(-1);
            DateTime dayStart = RadScheduler1.UtcDayStart(start);
            sessApts.Add(new AppointmentInfo("Bob's Birthday", dayStart, dayStart.AddDays(1), string.Empty, null, string.Empty, 1));
            sessApts.Add(new AppointmentInfo("Call Charlie about the Project", start.AddHours(2), start.AddHours(3), string.Empty, null, string.Empty, 2));
 
            start = start.AddDays(2);
            sessApts.Add(new AppointmentInfo("Get the car from the service", start.AddHours(2), start.AddHours(3), string.Empty, null, string.Empty, 1));
        }
        private AppointmentInfo FindById(object ID)
        {
            foreach (AppointmentInfo ai in sessApts)
            {
                if (ai.ID.Equals(ID))
                {
                    return ai;
                }
            }
 
            return null;
        }
 
    }
    class AppointmentInfo
    {
        private readonly string _id;
        private string _subject;
        private DateTime _start;
        private DateTime _end;
        private string _recurrenceRule;
        private string _recurrenceParentId;
        private string _reminder;
        private int? _userID;
 
        public string ID
        {
            get { return _id; }
        }
 
        public string Subject
        {
            get { return _subject; }
            set { _subject = value; }
        }
 
        public DateTime Start
        {
            get { return _start; }
            set { _start = value; }
        }
 
        public DateTime End
        {
            get { return _end; }
            set { _end = value; }
        }
 
        public string RecurrenceRule
        {
            get { return _recurrenceRule; }
            set { _recurrenceRule = value; }
        }
 
        public string RecurrenceParentID
        {
            get { return _recurrenceParentId; }
            set { _recurrenceParentId = value; }
        }
 
        public int? UserID
        {
            get { return _userID; }
            set { _userID = value; }
        }
 
        public string Reminder
        {
            get { return _reminder; }
            set { _reminder = value; }
        }
 
        private AppointmentInfo()
        {
            _id = Guid.NewGuid().ToString();
        }
 
        public AppointmentInfo(string subject, DateTime start, DateTime end,
            string recurrenceRule, string recurrenceParentID, string reminder, int? userID)
            : this()
        {
            _subject = subject;
            _start = start;
            _end = end;
            _recurrenceRule = recurrenceRule;
            _recurrenceParentId = recurrenceParentID;
            _reminder = reminder;
            _userID = userID;
        }
 
        public AppointmentInfo(Appointment source)
            : this()
        {
            CopyInfo(source);
        }
 
        public void CopyInfo(Appointment source)
        {
            Subject = source.Subject;
            Start = source.Start;
            End = source.End;
            RecurrenceRule = source.RecurrenceRule;
            if (source.RecurrenceParentID != null)
            {
                RecurrenceParentID = source.RecurrenceParentID.ToString();
            }
 
            if (!String.IsNullOrEmpty(Reminder))
            {
                Reminder = source.Reminders[0].ToString();
            }
 
            Resource user = source.Resources.GetResourceByType("User");
            if (user != null)
            {
                UserID = (int?)user.Key;
            }
            else
            {
                UserID = null;
            }
        }
    }
}

Ajax is working but i dont see loading panel icon.Please advise

Thanks
Ronak
0
Maria Ilieva
Telerik team
answered on 14 Feb 2012, 03:09 PM
Hi Ronak,

The provided code looks correct to me and I'm not able to isolate any obvious reason for the LoadingPanel issue you are facing. In this case it will be bets if you could open a regular support ticket and send us sample runnable version of your WebPart. Thus we will be able to deploy it locally, debug the code and do our best ti isolate the root cause of the issue.


Greetings,
Maria Ilieva
the Telerik team
Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
0
Ronak
Top achievements
Rank 1
answered on 15 Feb 2012, 04:10 PM
Thanks Maria,I will coordinate with guy here who is responsible for Creating Ticket.

Thanks
Ronak
Tags
General Discussions
Asked by
Ronak
Top achievements
Rank 1
Answers by
Maria Ilieva
Telerik team
Ronak
Top achievements
Rank 1
Share this question
or