Skip Navigation LinksHome / Community & Support / Developer Productivity Tools Forums / ASP.NET AJAX > Beta Forum > Q1 2011 - RadScheduler - AppTemplate

Not answered Q1 2011 - RadScheduler - AppTemplate

Feed from this thread
  • Jean-Yves avatar

    Posted on Mar 7, 2011 (permalink)

    Hello, 

    I'm testing the new Q1 2011 ASP.NET pack. And it looks great. :)

    I have a problem on the RadScheduler component.

    In the page_load I use : 
    RadSchedulerPlanning.AppointmentTemplate = new AppTemplate();

    And it refer to this code : 

    public class AppTemplate : ITemplate
            {
                public void InstantiateIn(Control container)
                {
                    var recurrenceIcon = new WebControl(HtmlTextWriterTag.Div);
                    recurrenceIcon.DataBinding += RecurrenceIcon_DataBinding;
                    container.Controls.Add(recurrenceIcon);
     
                    var subject = new Literal();
                    subject.DataBinding += Subject_DataBinding;
                    container.Controls.Add(subject);
                }
     
                private static void RecurrenceIcon_DataBinding(object sender, EventArgs e)
                {
                    var recurrence = (WebControl)sender;
                    var aptCont = (SchedulerAppointmentContainer)recurrence.Parent;
                    Appointment app = aptCont.Appointment;
     
                    var idCalendar = Convert.ToInt32(app.ID);
                    var calendar = BLLCalendar.GetCalendar(idCalendar);
     
                    if (calendar.IsValider)
                    {
                        recurrence.CssClass = "RadSchedulerValide";
                    }
                    if (calendar.IsSaisie)
                    {
                        recurrence.CssClass = "RadSchedulerSaisie";
                    }
                }
     
                private static void Subject_DataBinding(object sender, EventArgs e)
                {
                    var subject = (Literal)sender;
                    var aptCont = (SchedulerAppointmentContainer)subject.Parent;
                    Appointment app = aptCont.Appointment;
     
                    var idCalendar = Convert.ToInt32(app.ID);
                    var calendar = BLLCalendar.GetCalendar(idCalendar);
     
                    app.CssClass = SchedulerCSS.getCSSHeures(calendar.CodeHeure);
                    String numAffaire, com;
                    try
                    {
                        numAffaire = calendar.Affaire.Num;
                        com = calendar.Affaire.Libelle;
                    }
                    catch
                    {
                        numAffaire = calendar.CodeHeure1.Libelle;
                        com = "";
                    }
     
                    if (calendar.IsSaisie || calendar.IsValider)
                    {
                        app.AllowEdit = false;
                        app.AllowDelete = false;
                    }
     
                    subject.Text = String.Format("{0} - {1}", calendar.Temps, numAffaire);
                    app.ToolTip = com;
                    if (calendar.Commentaire != "")
                    {
                        app.ToolTip += " Com :" + calendar.Commentaire;
                    }
                }
            }


    With the previous version this code was working just fine. With this, I can put an icon infront of the appointment (Like in the picture).



    But now, with the 2011 Q1, when I want to interact with an appointment, I have this message : 
    Échec du chargement de viewstate. L'arborescence du contrôle sur lequel viewstate est chargé doit correspondre à l'arborescence du contrôle qui a été utilisé pour enregistrer viewstate lors de la demande précédente. Par exemple, lors de l'ajout dynamique de contrôle, les contrôles ajoutés lors d'une publication doivent correspondre au type et à la position des contrôles ajoutés lors de la demande initiale.
     
    Fr to En :
    Failed to load viewstate. The control tree on which viewstate is loaded must
    match the control tree that was used to save viewstate during the
    previous request. For example, when adding controls dynamically, the controls added during
    publication must match the type and position of the controls added during the
    initial application.

    And if I remove the RadSchedulerPlanning.AppointmentTemplate = new AppTemplate();
    It's working (The CRUD), but without the template!

    Is their a new way to use templates?


    Thank you 

    Jean-Yves
    Attached files

    Reply

  • Peter Peter admin's avatar

    Posted on Mar 9, 2011 (permalink)

    Hello Jean-Yves,

    Please, try setting the AppointmentTemplate in OnInit as this is the best event for this purpose:

    protected override void OnInit(EventArgs e)
      {
          base.OnInit(e);
          RadScheduler1.AppointmentTemplate = new AppTemplate();
      }

    I hope this helps.

    Regards,
    Peter
    the Telerik team
    Registration for Q1 2011 What’s New Webinar Week is now open. Mark your calendar for the week starting March 21st and book your seat for a walk through all the exciting stuff we ship with the new release!

    Reply

  • Jean-Yves avatar

    Posted on Mar 10, 2011 (permalink)

    Hello, 

    It's working like this :).
    So, some people will have to move their code a bit maybe.

    Thank you

    Jean-Yves

    Reply

Back to Top

Skip Navigation LinksHome / Community & Support / Developer Productivity Tools Forums / ASP.NET AJAX > Beta Forum > Q1 2011 - RadScheduler - AppTemplate