0

I use for a calendar which displays value in TextBox1. This TextBox AutoPostBack property is true. Because when the date changes i make some calculations based on the date. The calendar appears. But the page makes a loop of PostBacks. When i make TextBox1.AutoPostBack=false it works fine but i loose calculations.

How can i use with AutoPostBack TextBox?

<script type="text/javascript">
  var picker = new Pikaday({
    field: document.getElementById('<%= TextBox1.ClientID %>'),
    format: 'yyyy/MM/dd',
    toString(date, format) {
      const day = date.getDate();
      const month = date.getMonth() + 1;
      const year = date.getFullYear();
      return `${year}/${month}/${day}`;
    },
    parse(dateString, format) {
      // dateString is the result of `toString` method
      const parts = dateString.split('/');
      const day = parseInt(parts[0], 10);
      const month = parseInt(parts[1] - 1, 10);
      const year = parseInt(parts[1], 10);
      return new Date(year, month, day);
    }
  });
</script>
wael
  • 1
  • 3

0 Answers0