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

Accessing Controls in Customized Advanced Edit Form

1 Answer 77 Views
Scheduler
This is a migrated thread and some comments may be shown as answers.
steve matheson
Top achievements
Rank 2
steve matheson asked on 30 Mar 2009, 07:21 AM
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 =

"06/28/09"
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

 

1 Answer, 1 is accepted

Sort by
0
Accepted
Genady Sergeev
Telerik team
answered on 31 Mar 2009, 12:42 PM
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.

Greetings,
Genady Sergeev
the Telerik team

Check out Telerik Trainer , the state of the art learning tool for Telerik products.
Tags
Scheduler
Asked by
steve matheson
Top achievements
Rank 2
Answers by
Genady Sergeev
Telerik team
Share this question
or