Inherited RadDatePicker Server Control; Client Script Not Working

4 posts, 0 answers
  1. Mark Sternig
    Mark Sternig avatar
    12 posts
    Member since:
    Sep 2006

    Posted 12 Feb 2009 Link to this post

    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!

     

  2. Vlad
    Admin
    Vlad avatar
    11100 posts

    Posted 16 Feb 2009 Link to this post

    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.
  3. vaibhav
    vaibhav avatar
    8 posts
    Member since:
    Oct 2010

    Posted 19 Nov 2010 Link to this post

    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....
  4. vaibhav
    vaibhav avatar
    8 posts
    Member since:
    Oct 2010

    Posted 19 Nov 2010 Link to this post

    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....
Back to Top