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

Access the controls in Radscheduler Advanced Form

13 Answers 594 Views
Scheduler
This is a migrated thread and some comments may be shown as answers.
arockiasamy
Top achievements
Rank 1
arockiasamy asked on 23 Jun 2010, 12:58 PM
Dear,
How to access the controls , example subject textbox and description textbox found in scheduler Advanced Form (by clicking options). I would like to open in edit mode only (not insert mode) and assign some text in description textbox. How to do?

Kind regards
Arockiasamy

13 Answers, 1 is accepted

Sort by
0
vinoth
Top achievements
Rank 1
answered on 25 Jun 2010, 08:03 AM
Hi Arokiasamy,

If you are using AdvancedForm usercontrol, then you can acess the Subject Textbox by using the below code. If you want to change the subject text in edit mode, use the below code:

 

 

 

protected void RadScheduler1_FormCreated(object sender, SchedulerFormCreatedEventArgs e)  
{  
if (e.Container.Mode == SchedulerFormMode.AdvancedEdit)  
{  
  RadTextBox subtxt = (RadTextBox)e.Container.Controls[1].Controls[1].Controls[1].FindControl("SubjectText");  
  subtxt.text = "Something";  
}  
}  
 

Thanks,
Vinoth

0
arockiasamy
Top achievements
Rank 1
answered on 28 Jun 2010, 08:50 AM
not working (null object returned) Q32009 version
0
Veronica
Telerik team
answered on 30 Jun 2010, 11:04 AM
Hello arockiasamy,

Here's the code for setting the decription and subject :

protected void RadScheduler1_FormCreated(object sender, SchedulerFormCreatedEventArgs  e)
   {
       if (e.Container.Mode == SchedulerFormMode.AdvancedEdit)
       {
           RadTextBox txtSubject = (RadTextBox)e.Container.FindControl("Subject");
           txtSubject.Text = "Testing Subject :)";
           RadTextBox txtDescription = (RadTextBox)e.Container.FindControl("Description");
           txtDescription.Text = "Some description here ...";
       }
   }

It looks similar to that posted by vinoth kumar, but this one is the correct. Please find the differences and test it.

Find the full code in the attached .zip file.

Sincerely yours,
Veronica Milcheva
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
abm
Top achievements
Rank 1
answered on 15 Oct 2010, 03:47 PM

Hello Veronica,

Your following code regarding how to acces the controls in the Radscheduler Advanced Forms is very helpful and works nicely.

protected void RadScheduler1_FormCreated(object sender, SchedulerFormCreatedEventArgs  e)
   {
       if (e.Container.Mode == SchedulerFormMode.AdvancedEdit)
       {
           RadTextBox txtSubject = (RadTextBox)e.Container.FindControl("Subject");
           txtSubject.Text = "Testing Subject :)";
           RadTextBox txtDescription = (RadTextBox)e.Container.FindControl("Description");
           txtDescription.Text = "Some description here ...";
       }
   }

However, I would also like to access other controls on the form such as the "All day" check box and the radio buttons in the recurrence section. Can you kindly show how to do that? I suppose we can use the above method, only we will need the appropriate ID of each control. Is there any documentation that we can access regarding this?

With best regards,

Kabir

0
Stuart Hemming
Top achievements
Rank 2
answered on 17 Oct 2010, 10:17 AM
Kabir, 

You can just look at the source of the AdvanceForm template to find the relevant IDs the all you need do is use that value in FindControl and cast the result to the correct type.

-- 
Stuart - Don't forget to mark the comment as "Answer" if this helps.
0
abm
Top achievements
Rank 1
answered on 18 Oct 2010, 04:03 PM
Hi Stuart,

Thanks for you help. It would be nice if you could provide a link to the Advance Form template source.

Much appreciated.

Kabir
0
Stuart Hemming
Top achievements
Rank 2
answered on 18 Oct 2010, 04:18 PM
Kabir,

The source is on your local machine. Look in the telerik installation directory and you'll find it hidden in the Live Demos folder. Your installation may be slightly different, but on my machine you'd find 'em at "\Telerik\RadControls for ASP.NET AJAX Q2 2010\Live Demos\Scheduler\Examples\AdvancedFormTemplate\".

Hope that helps.

-- 
Stuart
0
abm
Top achievements
Rank 1
answered on 19 Oct 2010, 06:38 PM
Hi Stuart,

Thanks very much for the info. I have found the the folder containing the template files. The id of the controls are a bit different, for example, in Veronica's post the id of the subject text box is "Subject" while in the demo template file it is "SubjectText" (Q3 2009). Could be a different version, but I am using Q3 2009 and Veronica's code works perfectly for me, while if I try to use "SubjectText", I get a null error - seems strange.

Kabir
0
Stuart Hemming
Top achievements
Rank 2
answered on 20 Oct 2010, 08:36 AM
Kabir,

Not that strange.

I think believe the docs, and even the installed template code, is a bit behind the curve.

You wouldn't I guess, need to modify the code in Veronica's example so that the control names in /her/ code match the control names in /your/ code.

-- 
Stuart
0
Stuart Hemming
Top achievements
Rank 2
answered on 20 Oct 2010, 08:40 AM
Kabir,

If you go and have a look at this post, you will see that Veronica made available later versions of the templates that seem to work out-of-the-box for the current (Q2 2010 SP2) release.

-- 
Stuart
0
Larevenge
Top achievements
Rank 1
answered on 12 Nov 2010, 11:25 AM
@Veronica Milcheva

What vinoth was posting and what you were posting is both correct. users should check if they have the advancedform demo, if they have the controls inside a panel, if its one panel surrounding, you have to go one deeper, so you will get

RadComboBox

 

rcb_Adviseurs = (RadComboBox)e.Container.Controls[1].FindControl("rcb_Adviseurs");

 

 


Got confused, why mine wasnt working, got around this solution, still didn't work, then i tried Controls[1] and it worked.Tnx for the info anyways.
0
Veronica
Telerik team
answered on 17 Nov 2010, 12:59 PM
Hi Larevenge,

I'm glad you successfully got around the solution.

Usually e.Container.FindControl will be enough to access the controls in the Advanced Form. If you put a breakpoint  - you will see that e.Container represents the Advanced Form. I am surprised that you need to go one level further to access the RadComboBox as the "Subject" Textbox is in Panel called "BasicControlsPanel" and this line:

RadTextBox txtSubject = (RadTextBox)e.Container.FindControl("Subject"); 

successfully finds the subject TextBox without the need of Controls[1].

I am interested  are you using Template to customize the Advanced Form or how did you add the RadComboBox to the advanced form?

Best wishes,
Veronica Milcheva
the Telerik team
Browse the vast support resources we have to jumpstart your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
0
Chris
Top achievements
Rank 1
answered on 14 Apr 2011, 09:46 PM
For anyone who wants to access any control within RadScheduler's default advanced form:

Obviously you must know the ID of the control you want in order to call FindControl(), and if you also need to modify properties that are not part of the base System.Web.UI.Control class, you must know the exact type as well. The live demo files that Stuart Hemming mentioned are just that: demo files that may not exactly match Telerik's source for the advanced form. To retrieve the actual IDs and types in use, I wrote up this small block of code:

Dim msg As String = ""
FindControls(e.Container.Controls, msg)
 
Private Sub FindControls(ByVal col As ControlCollection, ByRef msg As String)
    For Each ctl As Control In col
        If ctl.ID <> "" Then
            If msg = "" Then
                msg = ctl.ID & " (" & ctl.GetType.ToString & ")"
            Else
                msg = msg & " - " & ctl.ID & " (" & ctl.GetType.ToString & ")"
            End If
        End If
 
        FindControls(ctl.Controls, msg)
    Next ctl
End Sub

This code produces the following value for msg during an insert:

AdvancedEditCloseButton (System.Web.UI.WebControls.LinkButton) - BasicControlsPanel (System.Web.UI.WebControls.Panel) - Subject (Telerik.Web.UI.RadTextBox) - StartDate (Telerik.Web.UI.RadDatePicker) - dateInput (Telerik.Web.UI.DatePickingInput) - popupButton (Telerik.Web.UI.CalendarPopupButton) - calendar (Telerik.Web.UI.DatePickingCalendar) - StartTime (Telerik.Web.UI.RadTimePicker) - dateInput (Telerik.Web.UI.DatePickingInput) - popupButton (Telerik.Web.UI.CalendarPopupButton) - calendar (Telerik.Web.UI.DatePickingCalendar) - timePopupLink (Telerik.Web.UI.TimePopupButton) - timeView (Telerik.Web.UI.RadTimeView) - tdl (Telerik.Web.UI.TimeDataList) - EndDate (Telerik.Web.UI.RadDatePicker) - dateInput (Telerik.Web.UI.DatePickingInput) - popupButton (Telerik.Web.UI.CalendarPopupButton) - calendar (Telerik.Web.UI.DatePickingCalendar) - EndTime (Telerik.Web.UI.RadTimePicker) - dateInput (Telerik.Web.UI.DatePickingInput) - popupButton (Telerik.Web.UI.CalendarPopupButton) - calendar (Telerik.Web.UI.DatePickingCalendar) - timePopupLink (Telerik.Web.UI.TimePopupButton) - timeView (Telerik.Web.UI.RadTimeView) - tdl (Telerik.Web.UI.TimeDataList) - AllDayEvent (System.Web.UI.WebControls.CheckBox) - SubjectValidator (System.Web.UI.WebControls.RequiredFieldValidator) - DurationValidator (System.Web.UI.WebControls.CustomValidator) - StartDateValidator (System.Web.UI.WebControls.RequiredFieldValidator) - StartTimeValidator (System.Web.UI.WebControls.RequiredFieldValidator) - EndDateValidator (System.Web.UI.WebControls.RequiredFieldValidator) - EndTimeValidator (System.Web.UI.WebControls.RequiredFieldValidator) - AdvancedControlsPanel (System.Web.UI.WebControls.Panel) - AttributeControls (System.Web.UI.WebControls.WebControl) - ResourceControls (System.Web.UI.WebControls.WebControl) - Description (Telerik.Web.UI.RadTextBox) - ButtonsPanel (System.Web.UI.WebControls.Panel) - InsertButton (System.Web.UI.WebControls.LinkButton) - CancelButton (System.Web.UI.WebControls.LinkButton) - SharedCalendar (Telerik.Web.UI.RadCalendar)

Now you can hide, change, do whatever you want to the built-in controls from the FormCreated event. I was using the Q1 2011 version of the ASP.NET AJAX suite.

Side note:
I never knew about the Label property of the RadTextBox and how you can use it to automatically render a label. Telerik is using that technique in the built-in form, so If you want to hide one of the labels just set the Label property of the appropriate RadTextBox to "".
Tags
Scheduler
Asked by
arockiasamy
Top achievements
Rank 1
Answers by
vinoth
Top achievements
Rank 1
arockiasamy
Top achievements
Rank 1
Veronica
Telerik team
abm
Top achievements
Rank 1
Stuart Hemming
Top achievements
Rank 2
Larevenge
Top achievements
Rank 1
Chris
Top achievements
Rank 1
Share this question
or