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

Not able to make Datepicker visible true at client side

1 Answer 285 Views
Calendar
This is a migrated thread and some comments may be shown as answers.
Ankit
Top achievements
Rank 1
Ankit asked on 11 Nov 2011, 06:30 AM
I have a usercontrol inside a radajaxpanel of my aspx page. I have a datepicker in this usercontrol.
On page load I have made the datepicker visible false as :-
DateRange.EndDateControl.Style.Value = "display: none";
I need to make the datepicker visible true at client side on onclick of checkbox. I have written a call back function as :-
function MakeControlsVisible(CheckBoxControl) {
                 var endDateControl = "<%= DateRange.EndDateControl.ClientID %>";
        var datePicker = document.getElementById(endDateControl);
  
                    if (CheckBoxControl.checked == true) {
                        datePicker.style.display = "block";
                    }
                                   }
Even after making the datepicker style "display:block" , I am not able to see the datepicker on my page. Can you help me what is going wrong?

1 Answer, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 11 Nov 2011, 06:57 AM
Hello Ankit,

You can try the following code snippet.

C#:
protected void Page_Load(object sender, EventArgs e)
 {
   CheckBox1.Attributes.Add("onclick","clickon();");
 }

JS:
<script type="text/javascript">
  function clickon()
  {
     var chk = document.getElementById("CheckBox1");
     var dtpcr = $find("<%=RadDatePicker1.ClientID %>");
     if (chk.checked == true)
     {
       dtpcr.set_enabled(true);
     }
     else
     {
       dtpcr.set_enabled(false);
     }
  }
</script>

Thanks,
Princy.
Tags
Calendar
Asked by
Ankit
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Share this question
or