Access the controls in Radscheduler Advanced Form

14 posts, 0 answers
  1. arockiasamy
    arockiasamy avatar
    11 posts
    Member since:
    Jun 2010

    Posted 23 Jun 2010 Link to this post

    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
  2. vinoth
    vinoth avatar
    2 posts
    Member since:
    Jun 2010

    Posted 25 Jun 2010 Link to this post

    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

  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. arockiasamy
    arockiasamy avatar
    11 posts
    Member since:
    Jun 2010

    Posted 28 Jun 2010 Link to this post

    not working (null object returned) Q32009 version
  5. Veronica
    Admin
    Veronica avatar
    1213 posts

    Posted 30 Jun 2010 Link to this post

    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
  6. abm
    abm avatar
    5 posts
    Member since:
    Jun 2008

    Posted 15 Oct 2010 Link to this post

    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

  7. Stuart Hemming
    Stuart Hemming avatar
    1622 posts
    Member since:
    Jul 2004

    Posted 17 Oct 2010 Link to this post

    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.
  8. abm
    abm avatar
    5 posts
    Member since:
    Jun 2008

    Posted 18 Oct 2010 Link to this post

    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
  9. Stuart Hemming
    Stuart Hemming avatar
    1622 posts
    Member since:
    Jul 2004

    Posted 18 Oct 2010 Link to this post

    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
  10. abm
    abm avatar
    5 posts
    Member since:
    Jun 2008

    Posted 19 Oct 2010 Link to this post

    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
  11. Stuart Hemming
    Stuart Hemming avatar
    1622 posts
    Member since:
    Jul 2004

    Posted 20 Oct 2010 Link to this post

    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
  12. Stuart Hemming
    Stuart Hemming avatar
    1622 posts
    Member since:
    Jul 2004

    Posted 20 Oct 2010 Link to this post

    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
  13. Larevenge
    Larevenge avatar
    38 posts
    Member since:
    Jul 2009

    Posted 12 Nov 2010 Link to this post

    @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.
  14. Veronica
    Admin
    Veronica avatar
    1213 posts

    Posted 17 Nov 2010 Link to this post

    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.
  15. Chris
    Chris avatar
    1 posts
    Member since:
    Mar 2011

    Posted 14 Apr 2011 Link to this post

    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 "".
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017