0

I'm pulling my hair over this, I can't get the Client-Side API of RadDatePicker to work. The object has no function or no properties.My want is simple just want to create a object of a RadDatePicker on javascript.please check the ClearControl function.just want to use set_selectedDate method on find datepicker control object.like:

 var today = new Date();
 var dateAcc = $find("<%=dtpDODate.ClientID %>");
 dateAcc.set_selectedDate(today);

Can you help me to find what is wrong with this code on a blank aspx page?

   <script type="text/javascript" language="javascript">
               function ClearControl(DivID) {
    try {
        var elements = null;
        if (DivID == null) {
            var oForm = document.forms['frmSiteMain'];
            if (!oForm) {
                oForm = document.form1;
            }
            elements = oForm.elements;
        }
        else {
            elements = document.getElementById(DivID).getElementsByTagName("input");
        }

        //  oForm.reset();
        for (i = 0; i < elements.length; i++) {
            if (elements[i].type != null) {
                field_type = elements[i].type.toLowerCase();

                if (field_type) {               

                        if ((elements[i].id.toString().search("body_") == 0 || elements[i].id.toString().search("ctl00_body_") == 0) && elements[i].id.toString().indexOf("_dtp") > 0) {
                               var today = new Date();
                            var control = $find(elements[i].id.toString());
                            control.set_selectedDate(today);                           
                            break;                         
                        }                  
                }
            }
        }

    }
    catch (e) {
        alert(e.message + " Type:" + field_type);
    }
}
</script>




    <div class="p_div" id="divDODate" runat="server">
        <div class="m1">
            <asp:Label ID="lblDODate" runat="server" Text="Date"></asp:Label>
            <telerik:RadDatePicker ID="dtpDODate" runat="server" MapColumnName="strDODate">
                <DateInput ID="DateInput1" DateFormat="MM/dd/yyyy" runat="server">
                </DateInput>

            </telerik:RadDatePicker>
        </div>
    </div>

Thanks for your assistance,

Tony L.
  • 17,638
  • 8
  • 69
  • 66
shamim
  • 6,640
  • 20
  • 85
  • 151

1 Answers1

0

The problem is specific , wrong object creation syntax,check the bellow sytax

 else if ((elements[i].id.toString().search("body_") == 0 || elements[i].id.toString().search("ctl00_body_") == 0) && elements[i].id.toString().indexOf("_dtp") > 0) {

                            var today = new Date();//get date
                            var control = $find(elements[i].id.toString());//create object of date picker control
                            control.set_selectedDate(today);//fill picker with date.
                            break;
                        }
shamim
  • 6,640
  • 20
  • 85
  • 151