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

Custom Attribute values missing on Insert

1 Answer 67 Views
Scheduler
This is a migrated thread and some comments may be shown as answers.
Benson
Top achievements
Rank 1
Benson asked on 08 May 2014, 10:06 PM
Dear Telerik Team,

I am trying to create scheduler with advanced insert/update templates. But below code fails to get attribute value during insert. Please advise.
 <telerik:RadScheduler runat="server" ID="RadScheduler1" Width="750px" OnDataBound="RadScheduler1_DataBound" StartInsertingInAdvancedForm="true"  OnAppointmentInsert="CMSScheduler_AppointmentInsert"
            AppointmentStyleMode="Default" AdvancedForm-EnableCustomAttributeEditing="true" OverflowBehavior="Auto"
             DataKeyField="ID" DataSubjectField="Subject" OnAppointmentCommand="RadScheduler1_AppointmentCommand" OnFormCreated="RadScheduler1_FormCreated" OnAppointmentDataBound="RadScheduler1_AppointmentDataBound"
            DataStartField="Start" DataEndField="End"
            CustomAttributeNames="FullName,Email,Phone"
            EnableDescriptionField="true" Skin="Windows7">
    <AdvancedForm Modal="true" />
    <DayView UserSelectable="true" />
    <WeekView UserSelectable="true" />
    <MonthView UserSelectable="true" />
    <DayView HeaderDateFormat="ddd dd MMMM yyyy" />
    <WeekView HeaderDateFormat="ddd dd MMMM yyyy" />
    <TimelineView HeaderDateFormat="ddd dd MMMM yyyy" />
    <MonthView HeaderDateFormat="MMMM yyyy" />
    <TimeSlotContextMenuSettings EnableDefault="true" />
    <AppointmentContextMenuSettings EnableDefault="true" />
              <AppointmentTemplate>
           
        </AppointmentTemplate>
        <AdvancedEditTemplate>
               <div class="rsAdvancedEdit" style="position: relative">  
                <%-- Title bar. --%> 
                <div class="rsAdvTitle">  
                    <%-- The rsAdvInnerTitle element is used as a drag handle when the form is modal. --%> 
                    <h1 class="rsAdvInnerTitle">  
                        </h1> 
                    <asp:LinkButton runat="server" ID="AdvancedEditCloseButton" CssClass="rsAdvEditClose" 
                        CommandName="Cancel" CausesValidation="false" ToolTip='close'>  
                        close  
                    </asp:LinkButton> 
                </div> 
            <div id="qsfexAdvEditWrapper">
                <div>
                    <div class="qsfexAdvAppType">
                    </div>
                   <div style="padding:10px;">
                     <table style="width:90%;">
                        <tr>
                        <td>Subject:</td>
                        <td><telerik:RadTextBox runat="server" ID="SubjectText" Width="70%" MaxLength="255" Text='<%# Eval("Subject") %>'  EnableSingleInputRendering="false"/></td>
                        </tr>
                        <tr>
                            <td colspan="2"  style="height:2px;">
                                  <asp:CustomValidator ID="CustomValidator1" runat="server"  ControlToValidate="SubjectText" ValidateEmptyText="true" ClientValidationFunction="ValidateRequired" />
                            </td>
                        </tr>
                         <tr>
                        <td>Full Name:</td>
                        <td> <telerik:RadTextBox ID="txtFullName" Width="70%" runat="server" MaxLength="100" Text='<%# Eval("FullName") %>' EnableSingleInputRendering="false" /></td>
                        </tr>
                         <tr>
                            <td colspan="2"  style="height:2px;">
                                 <asp:CustomValidator ID="CustomValidator2" runat="server"  ControlToValidate="txtFullName" ValidateEmptyText="true" ClientValidationFunction="ValidateRequired" />
                            </td>
                        </tr>
                         <tr>
                        <td>Phone:</td>
                        <td> <telerik:RadTextBox ID="txtPhone" runat="server" Width="70%" Text='<%# Eval("Phone") %>'  MaxLength="50"  EnableSingleInputRendering="false" /></td>
                        </tr>
                         <tr>
                            <td colspan="2"  style="height:2px;">
                                <asp:CustomValidator ID="CustomValidator3" runat="server"  ControlToValidate="txtPhone" ValidateEmptyText="true" ClientValidationFunction="ValidateRequired" />
                            </td>
                        </tr>
                         <tr>
                        <td>Email:</td>
                        <td> <telerik:RadTextBox ID="txtEmail" runat="server" Width="70%" Text='<%# Eval("Email") %>'  MaxLength="50" EnableSingleInputRendering="false"  /></td>
                        </tr>
                         <tr>
                            <td colspan="2"  style="height:2px;">
                                 <asp:CustomValidator ID="CustomValidator4" runat="server"  ControlToValidate="txtEmail" ValidateEmptyText="true" ClientValidationFunction="ValidateRequired" />
                            </td>
                        </tr>
                         <tr>
                        <td>Description:</td>
                        <td><telerik:RadTextBox runat="server" ID="DescriptionText" TextMode="MultiLine" Columns="50" MaxLength="1024"  Rows="10" Width="70%"  Text='<%# Eval("Description") %>' EnableSingleInputRendering="false"/></td>
                        </tr>
                         <tr>
                            <td colspan="2"  style="height:2px;"></td>
                        </tr>
                         <tr>
                        <td>Start:</td>
                        <td> <telerik:RadDateTimePicker ID="StartDate" runat="server" Width="70%" SelectedDate='<%# Bind("Start") %>' /></td>
                        </tr>
                         <tr>
                            <td colspan="2"  style="height:2px;"></td>
                        </tr>
                         <tr>
                        <td>End:</td>
                        <td> <telerik:RadDateTimePicker ID="EndDate" runat="server" Width="70%" SelectedDate='<%# Bind("End") %>' /></td>
                        </tr>
                         <tr>
                            <td colspan="2"  style="height:2px;"></td>
                        </tr>
                         <tr>
                            <td colspan="2" style="text-align:center;"> 
                                <asp:CompareValidator ID="valDateTimeOccurrenceDiscovery" runat="server" ControlToCompare="StartDate" ControlToValidate="EndDate" Operator="GreaterThan" ForeColor="Red" Display="Static" ErrorMessage="End Date/Time must be after Start Date/Time"></asp:CompareValidator> 
                            </td>
                        </tr>
                         <tr>
                        <td></td>
                        <td><div class="qsfexAdvEditControlWrapper" style="text-align: right;">
                        <asp:LinkButton ID="UpdateButton" runat="server" CommandName="Update">
                            <asp:Image runat="server" ID="insertImage" ImageUrl="Images/ok.png" AlternateText="update">
                            </asp:Image></asp:LinkButton>
                        <asp:LinkButton ID="UpdateCancelButton" runat="server" CausesValidation="False" CommandName="Cancel"
                            Style="margin-right: 8px;">
                            <asp:Image runat="server" ID="Image2" ImageUrl="Images/cancel.png" AlternateText="cancel">
                            </asp:Image></asp:LinkButton>
                    </div></td>
                        </tr>
                    </table>
                       </div>
            </div>
                </div>
                   </div>
        </AdvancedEditTemplate>
        <AdvancedInsertTemplate>
             <div class="rsAdvancedEdit" style="position: relative">  
                <%-- Title bar. --%> 
                <div class="rsAdvTitle">  
                    <%-- The rsAdvInnerTitle element is used as a drag handle when the form is modal. --%> 
                    <h1 class="rsAdvInnerTitle">  
                        </h1> 
                    <asp:LinkButton runat="server" ID="AdvancedEditCloseButton" CssClass="rsAdvEditClose" 
                        CommandName="Cancel" CausesValidation="false" ToolTip='close'>  
                        close  
                    </asp:LinkButton> 
                </div> 
            <div id="qsfexAdvEditWrapper">
                <div id="qsfexAdvEditInnerWrapper" class="technical">
                    <div class="qsfexAdvAppType">
                    </div>
                    <div style="padding:10px;">
                     <table style="width:90%;">
                        <tr>
                        <td>Subject:</td>
                        <td><telerik:RadTextBox runat="server" CssClass="txtBox" ID="SubjectText" Width="70%" MaxLength="255" Text='<%# Eval("Subject") %>'  EnableSingleInputRendering="false"/></td>
                        </tr>
                          <tr>
                            <td colspan="2"  style="height:2px;">
                               <asp:CustomValidator ID="CustomValidator1" runat="server"  ControlToValidate="SubjectText" ValidateEmptyText="true" ClientValidationFunction="ValidateRequired" />
                            </td>
                        </tr>
                         <tr>
                        <td>Full Name:</td>
                        <td> <telerik:RadTextBox ID="txtFullName" CssClass="txtBox" Width="70%" runat="server" MaxLength="100" Text='<%# Eval("FullName") %>' EnableSingleInputRendering="false" /></td>
                        </tr>
                          <tr>
                            <td colspan="2"  style="height:2px;">
                                 <asp:CustomValidator ID="CustomValidator2" runat="server"  ControlToValidate="txtFullName" ValidateEmptyText="true" ClientValidationFunction="ValidateRequired" />
                            </td>
                        </tr>
                         <tr>
                        <td>Phone:</td>
                        <td> <telerik:RadTextBox ID="txtPhone" CssClass="txtBox" runat="server" Width="70%"  MaxLength="50" Text='<%# Eval("Phone") %>'  EnableSingleInputRendering="false" /></td>
                        </tr>
                          <tr>
                            <td colspan="2"  style="height:2px;">
                                 <asp:CustomValidator ID="CustomValidator3" runat="server"  ControlToValidate="txtPhone" ValidateEmptyText="true" ClientValidationFunction="ValidateRequired" />
                            </td>
                        </tr>
                         <tr>
                        <td>Email:</td>
                        <td> <telerik:RadTextBox ID="txtEmail" runat="server" Width="70%"  MaxLength="50" EnableSingleInputRendering="false"  Text='<%# Eval("Email") %>' /></td>
                        </tr>
                          <tr>
                            <td colspan="2"  style="height:2px;">
                                 <asp:CustomValidator ID="CustomValidator4" runat="server"  ControlToValidate="txtEmail" ValidateEmptyText="true" ClientValidationFunction="ValidateRequired" />
                            </td>
                        </tr>
                         <tr>
                        <td>Description:</td>
                        <td><telerik:RadTextBox runat="server" ID="DescriptionText" TextMode="MultiLine" Columns="50" MaxLength="1024"  Rows="10" Width="70%"  Text='<%# Eval("Description") %>' EnableSingleInputRendering="false"/></td>
                        </tr>
                          <tr>
                            <td colspan="2"  style="height:2px;"></td>
                        </tr>
                         <tr>
                        <td>Start:</td>
                        <td> <telerik:RadDateTimePicker ID="StartDate" runat="server" Width="70%" SelectedDate='<%# Bind("Start") %>' TimeView-Interval="00:15:00" TimeView-Columns="4" TimeView-StartTime="6:00:00">     
                             </telerik:RadDateTimePicker></td>
                        </tr>
                          <tr>
                            <td colspan="2"  style="height:2px;"></td>
                        </tr>
                         <tr>
                        <td>End:</td>
                        <td> <telerik:RadDateTimePicker ID="EndDate" runat="server" Width="70%" SelectedDate='<%# Bind("End") %>' TimeView-Interval="00:15:00" TimeView-Columns="4" TimeView-StartTime="6:00:00">
                          
                             </telerik:RadDateTimePicker></td>
                        </tr>
                          <tr>
                            <td colspan="2"  style="height:2px;"></td>
                        </tr>
                          <tr>
                            <td colspan="2" style="text-align:center;">
                                <asp:CompareValidator ID="valDateTimeOccurrenceDiscovery" runat="server" ControlToCompare="StartDate" ControlToValidate="EndDate" Operator="GreaterThan" ForeColor="Red" Display="Static" ErrorMessage="End Date/Time must be after Start Date/Time"></asp:CompareValidator> 
                            </td>
                        </tr>
                         <tr>
                        <td></td>
                        <td><div class="qsfexAdvEditControlWrapper" style="text-align: right;">
                        <asp:LinkButton ID="InsertButton" runat="server" CommandName="Insert">
                            <asp:Image runat="server" ID="insertImage" ImageUrl="Images/ok.png" AlternateText="update">
                            </asp:Image></asp:LinkButton>
                        <asp:LinkButton ID="InsertCancelButton" runat="server" CausesValidation="False" CommandName="Cancel"
                            Style="margin-right: 8px;">
                            <asp:Image runat="server" ID="Image2" ImageUrl="Images/cancel.png" AlternateText="cancel">
                            </asp:Image></asp:LinkButton>
                    </div></td>
                        </tr>
                    </table>
                        </div>
                </div>
            </div>
                 </div>
        </AdvancedInsertTemplate>
        <TimeSlotContextMenuSettings EnableDefault="true"></TimeSlotContextMenuSettings>
        <AppointmentContextMenuSettings EnableDefault="true"></AppointmentContextMenuSettings>
    </telerik:RadScheduler>  public partial class Contact : Page
    {
        private const int AppointmentsLimit = 1;
        private DataTable dt = new DataTable();
        private CommonMethods cm;
        protected void Page_Load(object sender, EventArgs e)
        {
            cm = new CommonMethods();
            if (!Page.IsPostBack)
            {
                
                dt = cm.getDataTableNoParams("USP_GET_APPOINTMENTS");
                RadScheduler1.DataSource = dt;
                RadScheduler1.DataBind();
                RadScheduler1.SelectedDate = DateTime.Now;
            }
            else
            {
                dt = cm.getDataTableNoParams("USP_GET_APPOINTMENTS");
                RadScheduler1.DataSource = dt;
                RadScheduler1.DataBind();
            }

        }
        private void bindCMSScheduler()
        {
            dt = cm.getDataTableNoParams("USP_GET_APPOINTMENTS");
            RadScheduler1.DataSource = dt;
            RadScheduler1.Rebind();
        }

        protected void CMSScheduler_AppointmentInsert(object sender, SchedulerCancelEventArgs e)
        {
            try
            {
                string email = e.Appointment.Attributes["Email"].ToString(); // here this is null. No attributes find hre.
                cm.InsertNewAppointment(e);
                bindCMSScheduler();


            }
            catch (Exception ex)
            {
            }
            finally
            {
            }
        }

        protected void RadScheduler1_DataBound(object sender, EventArgs e)
        {
            //RadScheduler1.ResourceTypes.FindByName("User").AllowMultipleValues = true;
            //RadScheduler1.ResourceTypes.FindByName("Room").AllowMultipleValues = false;
        }

        protected void RadScheduler1_AppointmentDataBound(object sender, SchedulerEventArgs e)
        {
        }

        protected void RadScheduler1_FormCreated(object sender, SchedulerFormCreatedEventArgs e)
        {
            if ((e.Container.Mode == SchedulerFormMode.AdvancedEdit) || (e.Container.Mode == SchedulerFormMode.AdvancedInsert))
            {

               
            }

        }

        protected void validateEmail()
        {

        }

        protected void RadScheduler1_AppointmentCommand(object sender, AppointmentCommandEventArgs e)
        {
           

        }

    }
    {
        private const int AppointmentsLimit = 1;
        private DataTable dt = new DataTable();
        private CommonMethods cm;
        protected void Page_Load(object sender, EventArgs e)
        {
            cm = new CommonMethods();
            if (!Page.IsPostBack)
            {
                
                dt = cm.getDataTableNoParams("USP_GET_APPOINTMENTS");
                RadScheduler1.DataSource = dt;
                RadScheduler1.DataBind();
                RadScheduler1.SelectedDate = DateTime.Now;
            }
            else
            {
                dt = cm.getDataTableNoParams("USP_GET_APPOINTMENTS");
                RadScheduler1.DataSource = dt;
                RadScheduler1.DataBind();
            }

        }
        private void bindCMSScheduler()
        {
            dt = cm.getDataTableNoParams("USP_GET_APPOINTMENTS");
            RadScheduler1.DataSource = dt;
            RadScheduler1.Rebind();
        }

        protected void CMSScheduler_AppointmentInsert(object sender, SchedulerCancelEventArgs e)
        {
            try
            {
                string email = e.Appointment.Attributes["Email"].ToString(); // here this is null. No attributes find hre.
                cm.InsertNewAppointment(e);
                bindCMSScheduler();


            }
            catch (Exception ex)
            {
            }
            finally
            {
            }
        }

        protected void RadScheduler1_DataBound(object sender, EventArgs e)
        {
            //RadScheduler1.ResourceTypes.FindByName("User").AllowMultipleValues = true;
            //RadScheduler1.ResourceTypes.FindByName("Room").AllowMultipleValues = false;
        }

        protected void RadScheduler1_AppointmentDataBound(object sender, SchedulerEventArgs e)
        {
        }

        protected void RadScheduler1_FormCreated(object sender, SchedulerFormCreatedEventArgs e)
        {
            if ((e.Container.Mode == SchedulerFormMode.AdvancedEdit) || (e.Container.Mode == SchedulerFormMode.AdvancedInsert))
            {

               
            }

        }

        protected void RadScheduler1_AppointmentCommand(object sender, AppointmentCommandEventArgs e)
        {
           

        }

    }






1 Answer, 1 is accepted

Sort by
0
Boyan Dimitrov
Telerik team
answered on 13 May 2014, 02:20 PM
Hello,

I would suggest reviewing the following demo or the code library that shows our recommended approach for using custom attributes and custom advanced form. Please note the appointment color is custom attribute.

Regards,
Boyan Dimitrov
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
Tags
Scheduler
Asked by
Benson
Top achievements
Rank 1
Answers by
Boyan Dimitrov
Telerik team
Share this question
or