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

Access Controls Inside Radscheduler Templates

4 Answers 443 Views
Scheduler
This is a migrated thread and some comments may be shown as answers.
Glenn Boothe
Top achievements
Rank 1
Glenn Boothe asked on 11 Feb 2009, 04:00 PM

Hello,

I am having trouble finding the proper syntax for getting controls inside Radschedulers InlineInsertTemplate (or any other template for that matter)  I have read the articles in the KB about accessing controls inside templates dealing with RadMenu but none specifically dealing with RadScheduler.

I am trying to check the value of a textbox in my template on appointment insert to see if it has a value or not.  If not, I want to be able to insert some sort of default value into the appointment.  Whenever I try to access controls in the inline edit using schedule.FindControl("myTextBox") or schedule.NamingContainer.FindControl("myTextBox") I am met with an error

Object reference not set to an instance of an object.

Here is an example of the code I am trying to use.

    Protected Sub schedule_AppointmentInsert(ByVal sender As ObjectByVal e As Telerik.Web.UI.SchedulerCancelEventArgs) Handles schedule.AppointmentInsert  
 
        'Insert this dummy value into the textbox when appointment is being inserted  
        CType(schedule.FindControl("TitleTextBox"), TextBox).Text = "YO" 
 
    End Sub 

If anyone can help me out with this I would greatly appreciate it.

Thanks

4 Answers, 1 is accepted

Sort by
0
Accepted
Peter
Telerik team
answered on 13 Feb 2009, 02:51 PM
Hi Glenn,

One possible solution is to use RadTextBox and Custom Attributes. Handle the OnValueChanged client event of RadTextBox to store the value in a hidden fields control. Consider the following example:

 <telerik:RadScheduler ID="RadScheduler1" runat="server"     
     DataEndField="End"   
        DataKeyField="ID" DataRecurrenceField="RecurrenceRule"   
        DataRecurrenceParentKeyField="RecurrenceParentID"   
        DataSourceID="AccessDataSource1" DataStartField="Start"   
        DataSubjectField="Subject" HoursPanelTimeFormat="htt"   
        ValidationGroup="RadScheduler1" 
        CustomAttributeNames="Description"   
       EnableCustomAttributeEditing="true" 
        onappointmentinsert="RadScheduler1_AppointmentInsert" > 
        <InlineInsertTemplate > 
             <telerik:RadTextBox ID="RadTextBox2" Text='<%# Bind("Subject") %>' runat="server">  
            </telerik:RadTextBox> 
            <telerik:RadTextBox ID="RadTextBox1" Text='<%# Bind("Description") %>' ClientEvents-OnValueChanged="OnValueChanged" runat="server">  
            </telerik:RadTextBox> 
            <asp:LinkButton ID="insert1" runat="server" CommandName="Insert">insert</asp:LinkButton> 
       </InlineInsertTemplate> 
    </telerik:RadScheduler>     
    <script type="text/javascript">  
        function OnValueChanged(sender) {  
            var txbValue = document.getElementById("HiddenField1");  
            txbValue.value = sender.get_editValue();  
        }  
    </script> 
    <asp:HiddenField ID="HiddenField1" runat="server" /> 

 protected void RadScheduler1_AppointmentInsert(object sender, Telerik.Web.UI.SchedulerCancelEventArgs e)  
    {  
        if (HiddenField1.Value == String.Empty)  
        {  
            e.Appointment.Attributes["Description"] = "Yo";  
        }  
    } 



Regards,
Peter
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
SKS
Top achievements
Rank 1
answered on 14 Sep 2009, 05:17 PM
how do i insert a datagrid inside a radscheduler appointment. and bind it to a datasource?
y are these controls so complex.isnt their an easy way to customise these controls?
0
drgorin
Top achievements
Rank 1
answered on 25 Mar 2010, 12:38 PM
Using the OnValueChange event is extremely clever for getting a handle on the content of the textbox. I however have a slightly different situation and would appreciate some guidance or direction to a white paper.

I have a page that host's  radscheduler called radscheduler.aspx.  I have a custom attribute called PatientName.  I have a Button control in my inlineedit template that calls a radwindow that host's a page called PatientLookUp.aspx.  PatientLookUp has a datagrid filled with thousands of patient's data.  I return the patient's name to a javascript function as a pparameter on radsceduler.aspx upon closing PatientLookUp.aspx.  While I have the inlineedit template still open, I would like to insert the returned patient's name into the textbox or the label whoch is databound to the custom attribute PatientName.  How do I get a reference to the textbox or label that is databound to the custom attribute PatientName.  Access on the client please not the server.

DRG
0
Peter
Telerik team
answered on 29 Mar 2010, 01:46 PM
Hello Gorin,

We have replied to your support ticket suggesting two solutions to your requirement. I will post the one you said you prefer for community reference here:

<script type="text/javascript"
       var textboxInTemplate = null; 
       function OnLoad(sender) { 
           textboxInTemplate = sender; 
       
       function setTextBoxInSchedulerTemplate() { 
           if (textboxInTemplate) 
               textboxInTemplate.set_value("custom text here"); 
           textboxInTemplate = null; 
       
   </script
   <input id="Button1" type="button" value="set textbox value in inline template" onclick="setTextBoxInSchedulerTemplate()" /> 
   <telerik:RadScheduler runat="server" ID="RadScheduler1"
   StartEditingInAdvancedForm="false"
       <InlineEditTemplate
           <telerik:RadTextBox ID="RadTextBox1" runat="server" ClientEvents-OnLoad="OnLoad"
           </telerik:RadTextBox
       </InlineEditTemplate
   </telerik:RadScheduler>


Greetings,
Peter
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.
Tags
Scheduler
Asked by
Glenn Boothe
Top achievements
Rank 1
Answers by
Peter
Telerik team
SKS
Top achievements
Rank 1
drgorin
Top achievements
Rank 1
Share this question
or