Accessing Controls in Customized Advanced Edit Form

2 posts, 1 answers
  1. steve matheson
    steve matheson avatar
    28 posts
    Member since:
    Jul 2005

    Posted 30 Mar 2009 Link to this post

    I am using a customized advanced insert/edit form in the Q3 2008 version of the Scheduler.
    I am trying to set some of the default control properties for start date/time and end date/time by using the form created event and this vb code to set the value (in this example, of the EndDate):


    If e.Container.Mode = SchedulerFormMode.AdvancedInsert Then


    Dim enddateinput As RadDatePicker = New RadDatePicker


    enddateinput =

    DirectCast(e.Container.FindControl("EndDate"), RadDatePicker)


    enddateinput.SelectedDate =

    end if

    but I get a "object variable or with block variable not set"

    What is the correct way to access the controls in the customized advanced input form?

    steve m


  2. Answer
    Genady Sergeev
    Genady Sergeev avatar
    1600 posts

    Posted 31 Mar 2009 Link to this post

    Hi steve matheson,

    You can access the desired components directly in the Page_PreRender event of the SchedulerDefaultForm user control. Example:

    Protected Sub Page_PreRender(ByVal sender As ObjectByVal e As System.EventArgs) Handles Me.PreRender 
                Dim _startDate As Nullable(Of DateTime) 
                _startDate = StartDate.SelectedDate 
                StartDate.SelectedDate = New DateTime(3 / 31 / 2008) 
                If Not FormInitialized Then 
                    If IsAllDayAppointment(Appointment) Then 
                        EndDate.SelectedDate = EndDate.SelectedDate.Value.AddDays(-1) 
                    End If 
                    FormInitialized = True 
                End If 
            End Sub 

    Keep in mind that you cannot use FindControl directly in the FormCreated event of the RadScheduler because the AdvancedInsert/Edit form consists of several nested user controls and FindControl searches in the first container only. You can do the job by 5 nested FindControl invocations, but it is advisable not do so. I would suggest you to use the OnPreRender event instead.

    Genady Sergeev
    the Telerik team

    Check out Telerik Trainer , the state of the art learning tool for Telerik products.
Back to Top