Searching...
Jumat, 17 Juni 2016

How allow user to only view and select years with ajax calendar?



<form id="form1" runat="server">
<asp:scriptmanager id="ScriptManager1" runat="server" xmlns:asp="#unknown"></asp:scriptmanager>
<script type="text/javascript" language="javascript">
function onCalendarShown() {
   var cal = $find("calendar1");
   cal._switchMode("years", true);
   if (cal._yearsBody) {
      for (var i = 0; i < cal._yearsBody.rows.length; i++) {
         var row = cal._yearsBody.rows[i];
         for (var j = 0; j < row.cells.length; j++) {
             Sys.UI.DomEvent.addHandler(row.cells[j].firstChild, "click", call);
         }
        }
      }
   }

function onCalendarHidden() {
  var cal = $find("calendar1");
  if (cal._yearsBody) {
     for (var i = 0; i < cal._yearsBody.rows.length; i++) {
        var row = cal._yearsBody.rows[i];
        for (var j = 0; j < row.cells.length; j++) {
           Sys.UI.DomEvent.removeHandler(row.cells[j].firstChild, "click", call);
        }
     }
    }
}

function call(eventElement) {
   var target = eventElement.target;
   switch (target.mode) {
       case "year":
        var cal = $find("calendar1");
       cal.set_selectedDate(target.date);
       cal._blur.post(true);
       cal.raiseDateSelectionChanged(); break;
  }
}
</script>
<div>
<asp:textbox id="TextBox1" runat="server" xmlns:asp="#unknown"></asp:textbox>
<ajaxtoolkit:calendarextender id="TextBox1_CalendarExtender" runat="server" onclienthidden="onCalendarHidden" xmlns:ajaxtoolkit="#unknown">
 OnClientShown="onCalendarShown" Format="yyyy" BehaviorID="calendar1"  TargetControlID="TextBox1">


0 komentar:

Posting Komentar