One Clear Function for multiple RadDatePickers

2 posts, 0 answers
  1. Shawn
    Shawn avatar
    1 posts
    Member since:
    Mar 2013

    Posted 05 Mar 2013 Link to this post

    Scenario: You have a start date picker and an end date picker and you want a function that will clear either based on passing the id.   While I know this works:

    var StartDatePicker = $find("<%= dpStartDate.ClientID %>");
    StartDatePicker.clear();

    when we try to pass the id to a function something gets lost in the translation.  Is there any way to do something like:

    function clearDatePicker(id) {
         var picker = $find(id);
         picker.clear();
    }

    called by:

    <a href = "javascript: clearDatePicker('<%= dpStartDate.ClientID %.');">clear</a>
  2. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 05 Mar 2013 Link to this post

    Hello Shawn,

    Please have a look at the following code that works fine at my end. Your issue is you are not giving the client id correctly to the function in the hyperlink (href="javascript:clearAll('<%=RadDatePicker1.ClientID %.')")

    ASPX:
    <telerik:RadDatePicker ID="RadDatePicker1" runat="server">
    </telerik:RadDatePicker>
    <br /><br />
    <a href="javascript:clearAll('<%=RadDatePicker1.ClientID %>')">Clear All</a>

    JavaScript:
    <script type="text/javascript">
        function clearAll(id) {
            var picker = $find(id);
            picker.clear();
        }
    </script>

    Thanks,
    Princy
Back to Top