show Validate in Advances Form Edit message by server side

4 posts, 0 answers
  1. Francesco
    Francesco avatar
    16 posts
    Member since:
    Mar 2011

    Posted 22 Mar 2011 Link to this post

    hi, I have a simple Scheduler object. I would like make required the selection of resource in advances form edit for new appointment as the subject, can I do? I have found a trick to stop the execution server side using the  RadScheduler1_AppointmentInsert event, but not idea ho to show message.
    Thanks

    protected void RadScheduler1_AppointmentInsert(object sender, SchedulerCancelEventArgs e)
           {
               //cerco l'agente selezionato
               Resource UserRes = e.Appointment.Resources.GetResourceByType("Agente");
               if (UserRes != null)
               {
                  //DO BUSINESS
                   Appointments.Add(new TrilanceScheduleBase(e.Appointment));
               }
               else
               {
                   //STOP               
                   
    e.Cancel = true;
               }
           }


    <telerik:RadScheduler runat="server" ID="RadScheduler1" 
                                            DataKeyField="ID" DataSubjectField="Subject" DataStartField="Start" DataEndField="End"
                                            DayStartTime="07:00:00" DayEndTime="20:00:00" TimeZoneOffset="03:00:00" 
                                            OnAppointmentInsert="RadScheduler1_AppointmentInsert"
                                            OnAppointmentUpdate="RadScheduler1_AppointmentUpdate" 
                                            OnAppointmentDelete="RadScheduler1_AppointmentDelete"                                        
                                            DataRecurrenceField="RecurrenceRule" 
                                            DataRecurrenceParentKeyField="RecurrenceParentId" Height="100%" 
                                            onappointmentdatabound="RadScheduler1_AppointmentDataBound" 
                                            ondatabound="RadScheduler1_DataBound" Culture="Italian (Italy)" 
                                             EditFormTimeFormat="HH.mm" FirstDayOfWeek="Monday" HoursPanelTimeFormat="HH" 
                                             SelectedView="WeekView" StartInsertingInAdvancedForm="True" 
                                             onformcreating="RadScheduler1_FormCreating">
                                             <DayView DayEndTime="20:00:00" DayStartTime="07:00:00" 
                                                 WorkDayEndTime="20:00:00" WorkDayStartTime="07:00:00" />
                                             <AdvancedForm Modal="true" TimeFormat="HH.mm" />
                                             <TimelineView UserSelectable="false" />
                                             <WeekView DayEndTime="20:00:00" DayStartTime="07:00:00" 
                                                 WorkDayEndTime="07:00:00" WorkDayStartTime="20:00:00" />
                                             <TimeSlotContextMenuSettings EnableDefault="true" />
                                             <AppointmentContextMenuSettings EnableDefault="true" />                                        
                                         </telerik:RadScheduler>
  2. Veronica
    Admin
    Veronica avatar
    1213 posts

    Posted 22 Mar 2011 Link to this post

    Hi Francesco,

    You can use the RegisterStartupScript function to display an alert with corresponding message:

    ScriptManager.RegisterStartupScript(Page, GetType(), "alert", "alert('Please choose a resource!');", true);

    Hope this helps.

    Best wishes,
    Veronica Milcheva
    the Telerik team
  3. Francesco
    Francesco avatar
    16 posts
    Member since:
    Mar 2011

    Posted 22 Mar 2011 Link to this post

    thank to reply me. Show my picture. My question is if exist a method to call the validator/message in form to show a custom message. I have read in your documentation how to make a formadvance template but your interface is great and i don't won't to do by zero only for little customisation. I'm sure that there is a simple method. You exemple work but if the user show a message in form is bad show another in alert type.
    thank a lot
  4. Veronica
    Admin
    Veronica avatar
    1213 posts

    Posted 22 Mar 2011 Link to this post

    Hello Francesco,

    Yes, you are definitely right that a better way to show validation message is to keep it in the Advanced Form. However there is no easy way to do this without customizing the Advanced Form just to add a RequiredFieldValidator for the Resource. I know that it is not an easy approach and that's why I prepared a sample project for you.

    Please take a look at the project in the attached .zip file and let me know if this was helpful.

    Kind regards,
    Veronica Milcheva
    the Telerik team
Back to Top