Not able to make Datepicker visible true at client side

2 posts, 0 answers
  1. Ankit
    Ankit avatar
    12 posts
    Member since:
    Jul 2011

    Posted 11 Nov 2011 Link to this post

    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?
  2. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 11 Nov 2011 Link to this post

    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.
  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top