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

Inherited RadDatePicker Server Control; Client Script Not Working

3 Answers 109 Views
Calendar
This is a migrated thread and some comments may be shown as answers.
Mark Sternig
Top achievements
Rank 1
Mark Sternig asked on 12 Feb 2009, 05:09 PM
I have created a server control which inherits from the TadDatePicker web control using the code below.  It appears that all of the serverside properties and methods work flawlessly when I place my "DatePicker" control onto an ASP.NET webform.

 

 

    public class DatePicker : Telerik.Web.UI.RadDatePicker  
    {  
        protected override void OnLoad(EventArgs e)  
        {  
            //set default properties  
            Skin = "WebBlue";  
            Calendar.Skin = "WebBlue";  
            DateInput.Skin = "WebBlue";  
            DateInput.BackColor = System.Drawing.Color.White;  
            DateInput.Font.Bold = true;  
            Calendar.ShowRowHeaders = false;  
            Width = Unit.Pixel(120);  
              
            base.OnLoad(e);  
        }  
    } 

BUT.... When I try to access the client-side API I am not able to access any of the built-in methods or properties.  For example, I have a page with a dropdown on it.  When the dropdown's selection is chnaged, I am trying to clear the contents of my DatePicker control using javascript. Here is the code of a user control that encpsulates my server controls and the javascript:

 

<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="ucAssessmentTimePeriodSelection.ascx.cs" Inherits="BYOA.Admin.UserControls.ucAssessmentTimePeriodSelection" %> 
<%@ Register Assembly="SSG.WebControls" Namespace="SSG.WebControls.ServerControls" TagPrefix="cc2" %> 
<%@ Register Assembly="BYOA.Admin" Namespace="BYOA.Admin.ServerControls" TagPrefix="cc1" %> 
 
<script type="text/javascript">  
 
    function ClearDate()  
    {  
        var datePicker = document.getElementById('<%= dtStartDate.ClientID %>');  
        alert(datePicker.name);
        datePicker.clear();  
    }  
      
    function ClearTestingPeriod(sender, eventArgs)  
    {  
        var ddlTestingPeriod = document.getElementById('<%= ddlTestingPeriod.ClientID %>');  
        ddlTestingPeriod.selectedIndex = 0;  
    }  
</script> 
 
 
<cc1:TestingPeriodDropDownList runat="server" ID="ddlTestingPeriod" onChange="ClearDate();"></cc1:TestingPeriodDropDownList><br><br> 
 
<cc2:DatePicker runat="server" ID="dtStartDate">  
    <ClientEvents OnDateSelected="ClearTestingPeriod" /> 
</cc2:DatePicker> 
 

The error I am getting when the dropdown is changed is on the line "datePicker.clear();" which is:

"Object doesn't support this property or method."

I am able to do an alert(datePicker.name) and it works just fine, so I know that I at least am getting a reference to the object.  It appears that it does not understand the type of the object and that it is a RadDatePicker, and therefore doees not know what "obj.clear()" is.  Any help would be MOST appreciated!

 

3 Answers, 1 is accepted

Sort by
0
Vlad
Telerik team
answered on 16 Feb 2009, 07:00 AM
Hello Mark,

To get reference to ASP.NET AJAX component you should use $find().

Kind regards,
Vlad
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
vaibhav
Top achievements
Rank 1
answered on 19 Nov 2010, 10:38 AM
Hi Mark,

Can you please post you code for inheriting RADGrid.
I also need help about this.
So that i can take your code refrence.

Thanks.......in Advance....
0
vaibhav
Top achievements
Rank 1
answered on 19 Nov 2010, 10:39 AM
Sorry Mark,by mistakenely i wrote RADGrid, i need for RADDatepicker


Can you please post you code for inheriting RADDatepicker.
I also need help about this.
So that i can take your code refrence.

Thanks.......in Advance....
Tags
Calendar
Asked by
Mark Sternig
Top achievements
Rank 1
Answers by
Vlad
Telerik team
vaibhav
Top achievements
Rank 1
Share this question
or