I have seen a similar issue and client side solution for clearing the Telerik date picker on this forum, but for a dynamically added date picker I can't see the solution. The scenario is the following:
I have a grid where in each row a date picker sits with a clear button to remove the selected date. The grid is built from scratch in code behind and thus the client side clear action script must know which date picker to clear for each grid row.
I ttried to build the script as a string and adding to each grid row as a literal:
dpExpiryDatePicker = new Telerik.WebControls.RadDatePicker();
dpExpiryDatePicker.ID = "dpExpiryDatePicker_" + nCount;
dpExpiryDatePicker.ToolTip = "Select the date";
dpExpiryDatePicker.Width = Unit.Pixel(90);
dpExpiryDatePicker.MinDate = DateTime.Now.Date.AddDays(1);
"<script>" +
"function ClearExpiryDate()" +
"{" +
" var dpDatePicker = <%=" + dpExpiryDatePicker.ClientID+ "%>;" +
// "var dpDatePicker = $find(\"<%=" + dpExpiryDatePicker.ClientID+ "%>\");" +
"alert(dpDatePicker);" +
"if(dpDatePicker != null)" +
"{" +
" dpDatePicker.DateInput.Clear();" +
"}" +
"}" +
"</script>";
Can someone point out how to handle the clearing of each date picker added dynamically? Unfortunately the script above doesn't work, neither work the other commented out line. So how to achieve this?
I have a grid where in each row a date picker sits with a clear button to remove the selected date. The grid is built from scratch in code behind and thus the client side clear action script must know which date picker to clear for each grid row.
I ttried to build the script as a string and adding to each grid row as a literal:
dpExpiryDatePicker = new Telerik.WebControls.RadDatePicker();
dpExpiryDatePicker.ID = "dpExpiryDatePicker_" + nCount;
dpExpiryDatePicker.ToolTip = "Select the date";
dpExpiryDatePicker.Width = Unit.Pixel(90);
dpExpiryDatePicker.MinDate = DateTime.Now.Date.AddDays(1);
"<script>" +
"function ClearExpiryDate()" +
"{" +
" var dpDatePicker = <%=" + dpExpiryDatePicker.ClientID+ "%>;" +
// "var dpDatePicker = $find(\"<%=" + dpExpiryDatePicker.ClientID+ "%>\");" +
"alert(dpDatePicker);" +
"if(dpDatePicker != null)" +
"{" +
" dpDatePicker.DateInput.Clear();" +
"}" +
"}" +
"</script>";
Can someone point out how to handle the clearing of each date picker added dynamically? Unfortunately the script above doesn't work, neither work the other commented out line. So how to achieve this?