0

我已经实现了以下代码:此函数未调用

我的 HTML 代码是:

<asp:CalendarExtender ID="CalendarExtender1" runat="server" Format="dd/MM/yy" PopupButtonID="ImageButton1" PopupPosition="BottomRight" Enabled="true" OnClientDateSelectionChanged="DisableWeekends" TargetControlID="txtStartDate">

onclientshown=`"DisableWeekends"

函数如下:

function DisableWeekends(sender, args) {
  for (var i = 0; i < sender._days.all.length; i++) {
    for (var j = 0; j < 6; j++) {
      if (sender._days.all[i].id == "DisabledWeekendsCalendar" + j + "_5") {
        sender._days.all[i].disabled = true;
        sender._days.all[i].innerHTML = 
               "<div>" + sender._days.all[i].innerText + "</div>";
      }

      if (sender._days.all[i].id == "DisabledWeekendsCalendar" + j + "_6") {
        sender._days.all[i].disabled = true;
        sender._days.all[i].innerHTML = 
               "<div>" + sender._days.all[i].innerText + "</div>";
      }
    }
  }
}
4

2 回答 2

0

尝试这个

<script type="text/javascript">
        //disable sunday
        function detect_sunday(sender, args) {
            if (sender._selectedDate.getDay() == 0) {
                sender._selectedDate = new Date();
                // set the date back to the current date
                sender._textbox.set_Value(sender._selectedDate.format(sender._format));
                alert("You can't select sunday!");
            }
        }
    </script>

<asp:CalendarExtender ID="calenderExtender" runat="server" CssClass="cal_theme" TargetControlID="txtCalender"
            PopupButtonID="BtnCalender" OnClientDateSelectionChanged="detect_sunday"/>
于 2013-11-11T07:09:33.950 回答
0

使用 CSS

.DisableWeekends .ajax__calendar_days table tbody tr td:first-child
{

    text-decoration: line-through;
    color: red;
    pointer-events: none;
    cursor: default;
}

之后在控制器中添加DisableWeekends类。CalendarExtender

于 2020-02-25T11:48:27.530 回答