Show alert or run JavaScript function after showing the appointment popup in DevExpress using VB.NET

Show alert or run JavaScript function after showing the appointment popup in DevExpress using VB.NET

show alert or run javascript function after showing the appointment popup in devexpress using vb dot net

You should handle the CustomJSProperties event and add in properties collection the script which you are going to run it.
Please find below server side code:

Dim script As String = Nothing
Dim disablePopup As Boolean = false

Protected Sub ASPxScheduler1_AppointmentFormShowing(sender As Object, e As AppointmentFormEventArgs) Handles ASPxScheduler1.AppointmentFormShowing

        e.Container = New UserAppointmentFormTemplateContainer(CType(sender, ASPxScheduler))

        If disablePopup  Then
            script = "You do not have a permission to modify this appointment."
            e.Cancel = True
        Else
            script = Nothing
        End If

End Sub

    Protected Sub ASPxScheduler1_CustomJSProperties(sender As Object, e As DevExpress.Web.CustomJSPropertiesEventArgs) Handles ASPxScheduler1.CustomJSProperties

       e.Properties.Add("cpValue", script)

    End Sub

On the server side code you are going to add a client side event called EndCallback.
Please find below the client side code:

<dxwschs:ASPxScheduler ID="ASPxScheduler1" runat="server" ClientIDMode="AutoID" ClientInstanceName="scheduler" AppointmentDataSourceID="SqlDataSource1" Start="1753-01-01">
  <Storage>
    <Appointments AutoRetrieveId="True">
      <Mappings AllDay="AllDay" AppointmentId="UniqueID" Description="Description" End="EndDate" Label="Label" Location="Location" RecurrenceInfo="RecurrenceInfo" ReminderInfo="ReminderInfo" ResourceId="ResourceID" Start="StartDate" Status="Status" Subject="Subject" Type="Type" />
      <CustomFieldMappings>
        <dxwschs:ASPxAppointmentCustomFieldMapping Member="FilePath" Name="FilePath" />
        <dxwschs:ASPxAppointmentCustomFieldMapping Member="ApprovedImage" Name="ApprovedImage" />
        <dxwschs:ASPxAppointmentCustomFieldMapping Member="UserCompanyID" Name="UserCompanyID" />
      </CustomFieldMappings>
    </Appointments>
    <Resources>
      <Mappings Caption="ResourceName" Color="Color" Image="Image" ResourceId="ResourceID" />
    </Resources>
  </Storage>
  <Views>
    <DayView>
      <TimeRulers>
        <cc1:TimeRuler></cc1:TimeRuler>
      </TimeRulers>
      <Templates>

        <VerticalAppointmentTemplate>
          <VAppointmentTemplate:VerticalAppointmentTemplate runat="server" />
        </VerticalAppointmentTemplate>
      </Templates>
    </DayView>
    <WorkWeekView>
      <TimeRulers>
        <cc1:TimeRuler></cc1:TimeRuler>
      </TimeRulers>
      <Templates>
        <VerticalAppointmentTemplate>
          <VAppointmentTemplate:VerticalAppointmentTemplate runat="server" />
        </VerticalAppointmentTemplate>
      </Templates>
    </WorkWeekView>
    <WeekView Enabled="false"></WeekView>
    <FullWeekView Enabled="true">
      <TimeRulers>
        <cc1:TimeRuler></cc1:TimeRuler>
      </TimeRulers>
      <Templates>
        <VerticalAppointmentTemplate>
          <VAppointmentTemplate:VerticalAppointmentTemplate runat="server" />
        </VerticalAppointmentTemplate>
      </Templates>
    </FullWeekView>
  </Views>

  <ClientSideEvents EndCallback="function(s, e) { 
                                 if(scheduler.cpValue === null || scheduler.cpValue === undefined )
                                 {}else
                                 { alert(scheduler.cpValue);}
                                 }" />

  <OptionsCustomization AllowAppointmentDelete="None" AllowAppointmentDrag="None" />

  <OptionsForms AppointmentFormTemplateUrl="~/CustomSchedule/UserAppointmentForm.ascx" AppointmentInplaceEditorFormTemplateUrl="~/DevExpress/ASPxSchedulerForms/InplaceEditor.ascx" GotoDateFormTemplateUrl="~/DevExpress/ASPxSchedulerForms/GotoDateForm.ascx" RecurrentAppointmentDeleteFormTemplateUrl="~/DevExpress/ASPxSchedulerForms/RecurrentAppointmentDeleteForm.ascx" RecurrentAppointmentEditFormTemplateUrl="~/DevExpress/ASPxSchedulerForms/RecurrentAppointmentEditForm.ascx" RemindersFormTemplateUrl="~/DevExpress/ASPxSchedulerForms/ReminderForm.ascx" />
  <OptionsToolTips AppointmentDragToolTipUrl="~/DevExpress/ASPxSchedulerForms/AppointmentDragToolTip.ascx" AppointmentToolTipUrl="~/DevExpress/ASPxSchedulerForms/AppointmentToolTip.ascx" SelectionToolTipUrl="~/DevExpress/ASPxSchedulerForms/SelectionToolTip.ascx" />
</dxwschs:ASPxScheduler>

Share this post

Leave a Reply

Your email address will not be published. Required fields are marked *