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

Access to Advance Controls on FormCreated

3 Answers 132 Views
Scheduler
This is a migrated thread and some comments may be shown as answers.
GDPR_erased
Top achievements
Rank 1
GDPR_erased asked on 11 Nov 2008, 02:19 AM
After the Q3 upgrade, the routine I got from a blog I was refered too quit working. I need to access the Subject label and change the text, however, I have a java error about the parent control (Parent.Controls(0)). The error occurs at the bottom of this routing, (around line 69) but basically, some of this works and some of this does not.
I want to change subject text to say: "Event Summary". Can you help me?
Thanks,
~bg

    Protected Sub RadScheduler1_FormCreated(ByVal sender As Object, ByVal e As Telerik.Web.UI.SchedulerFormCreatedEventArgs) Handles RadScheduler1.FormCreated  
 
        HiddenFieldAppointmentID.Value = e.Container.Appointment.ID  
 
        grdEvent.DataBind()  
 
        If (e.Container.Mode = SchedulerFormMode.AdvancedEdit) OrElse (e.Container.Mode = SchedulerFormMode.AdvancedInsert) Then  
            'Find and hide the advanced control panel:  
            'Dim advancedPanel As Panel = DirectCast(e.Container.FindControl("AdvancedControlsPanel"), Panel)  
            'advancedPanel.Visible = false;  
 
            RadScheduler1.Height = 350 
 
            ''Find the Recurrency checkbox and hide it.  
            Dim recuranceCheckbox As CheckBox = DirectCast(e.Container.FindControl("RecurrentAppointment"), CheckBox)  
            recuranceCheckbox.Visible = False 
 
            ''Find the All Day checkbox and hide it.  
            Dim AllDayEvent As CheckBox = DirectCast(e.Container.FindControl("AllDayEvent"), CheckBox)  
            AllDayEvent.Visible = False 
 
            'Find the Subject textbox and set its Height:  
            Dim subjectTextbox As TextBox = DirectCast(e.Container.FindControl("Subject"), TextBox)  
            subjectTextbox.Height = Unit.Pixel(20)  
            subjectTextbox.MaxLength = 50 
            subjectTextbox.CssClass = "NormalBlack" 
            'subjectTextbox.BackColor = System.Drawing.Color.LemonChiffon  
 
            ''Find the DropDownList for the Room resource and set its SelectedIndex property.   
            ''This is useful if you want to default to a specific resource selection. However,  
            ''you should leave only the AdvancedInsert clause from the if statement above.   
            Dim resEventTypeDDL As DropDownList = DirectCast(e.Container.FindControl("resType"), DropDownList)  
            resEventTypeDDL.Width = 600 
            'resEventTypeDDL.SelectedIndex = 1 
 
            'Find the TextBox for the EventLocation custom attribute and set its properties:  
            Dim attrEventLocationTextbox As TextBox = DirectCast(e.Container.FindControl("AttrEventLocation"), TextBox)  
            'attrEventLocationTextbox.BackColor = System.Drawing.Color.LemonChiffon  
            attrEventLocationTextbox.MaxLength = 255 
            attrEventLocationTextbox.Width = 600 
            attrEventLocationTextbox.CssClass = "NormalBlack" 
 
            Dim attrEventDescriptionTextbox As TextBox = DirectCast(e.Container.FindControl("AttrEventDescription"), TextBox)  
            'attrEventDescriptionTextbox.BackColor = System.Drawing.Color.LemonChiffon  
            attrEventDescriptionTextbox.TextMode = TextBoxMode.MultiLine  
            attrEventDescriptionTextbox.Rows = 4 
            attrEventDescriptionTextbox.Width = 600 
            attrEventDescriptionTextbox.CssClass = "NormalBlack" 
 
            'The description labels for Subject, Resources and Custom Attributes require a different  
            'approach since they are WebControls which dynamically add a label.   
 
            'Change the description for the EventLocation attribute:  
            Dim attrWebcontrol1 As WebControl = DirectCast(e.Container.FindControl("LblAttrEventLocation"), WebControl)  
            Dim attrLabel1 As New Label()  
            attrLabel1.Text = "Location:" 
            attrWebcontrol1.Controls.Clear()  
            attrWebcontrol1.Controls.Add(attrLabel1)  
 
            Dim attrWebcontrol2 As WebControl = DirectCast(e.Container.FindControl("LblAttrEventDescription"), WebControl)  
            Dim attrLabel2 As New Label()  
            attrLabel2.Text = "Description:" 
            attrWebcontrol2.Controls.Clear()  
            attrWebcontrol2.Controls.Add(attrLabel2)  
 
            'Change the description for the Subject. Please, note that since the description control   
            'for Subject does not render an ID, you need to use the first child of the Parent control   
            'of the subject TextBox.  
            Dim subjectDescription As WebControl = DirectCast(subjectTextbox.Parent.Controls(0), WebControl)  
            Dim subjectLabel1 As New Label()  
            subjectLabel1.Text = "Event Summary:" 
            subjectDescription.Controls.Clear()  
 
            subjectDescription.Controls.Add(subjectLabel1)  
        End If  
    End Sub 

3 Answers, 1 is accepted

Sort by
0
GDPR_erased
Top achievements
Rank 1
answered on 11 Nov 2008, 02:30 AM
I think I got it....
lol it was in the very next post!
I replaced the bad with this newer part:
 
            Dim basicConrolsPanel As Panel = DirectCast(e.Container.FindControl("BasicControlsPanel"), Panel)  
            Dim subjectControl As WebControl = DirectCast(basicConrolsPanel.Controls(0).Controls(0), WebControl)  
            subjectControl.Controls.Clear()  
 
            Dim subjectLabel As New Label()  
            subjectLabel.Text = "Event Summary:" 
 
            subjectControl.Controls.Add(subjectLabel) 

And that works.
~bg
0
Peter
Telerik team
answered on 11 Nov 2008, 01:01 PM

Nice! The kb article on how to access controls in the advanced form will be updated shortly for Q3 2008 release. While experimenting with the new version, I came to exactly the same solution as yours. Thanks for posting it in the forums.


Greeings,
Peter
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Stephen
Top achievements
Rank 2
answered on 24 Dec 2008, 12:10 AM
I'm having some issues with Q3 when hiding the AllDayEvent checkbox. It hides no problems but the Reccurence checkbox no longer works. Checking it no longer shows the Reccurence panel. It's there but the style seems to be set to display: none?

CheckBox allDayCheckBox = (CheckBox)e.Container.FindControl("AllDayEvent");  
if (allDayCheckBox != null) allDayCheckBox.Visible = false;  
 

<div id="RadDock1_C_RadScheduler3_Form_RecurrencePanel" style="display: none;">  
<div id="RadDock1_C_RadScheduler3_Form_RecurrencePatternPanel" class="rsAdvRecurrencePatterns">  
</div> 
<div id="RadDock1_C_RadScheduler3_Form_RecurrenceRangePanel" class="rsAdvRecurrenceRangePanel">  
</div> 
</div> 

If I remove the Style="display: none;" using firebug in Firefox then it shows the panel.
making the alldaycheckbox.visible = false seems to break the RecurrentAppointment checkbox

is anyone else getting this?
Tags
Scheduler
Asked by
GDPR_erased
Top achievements
Rank 1
Answers by
GDPR_erased
Top achievements
Rank 1
Peter
Telerik team
Stephen
Top achievements
Rank 2
Share this question
or