本文介绍了如何禁用除星期一以外的日期到calendarextender C#的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何禁用除星期一以外的日期到calendarextender C#



我尝试过:



how to disable the dates other than monday into calendarextender C#

What I have tried:

<cc1:CalendarExtender ID="txtthu2_CalendarExtender" Format="dd/MM/yyyy" runat="server" TargetControlID="txtthu2" FirstDayOfWeek="Monday"  TodaysDateFormat="dd/MM/yyyy" >
</cc1:CalendarExtender>

推荐答案

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="MvcApplication2.WebForm1" %>
 

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <script>
        function DisableExceptMonday(sender,args) {
            for (var i = 0; i < 6; i++) {
                var row = sender._days.children[0].childNodes[1].children[i];
                for (var j = 0; j < 7; j++) {
                    var cell = row.children[j].firstChild;

                    if (cell.id != sender._id + "_day_" + i + "_" + "0") {
                        console.log(cell.id)
                         
                        cell.parentElement.className = 'ajax__calendar_invalid'
                    } 
                }
            }
        }
    </script>
</head>
<body>
  
   <form id="form1" runat="server">
        <asp:ScriptManager ID="ScriptManager1" runat="server" />
      
             <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
        <ajaxToolkit:CalendarExtender ID="TextBox1_CalendarExtender" runat="server" 
           
            Enabled="True" TargetControlID="TextBox1" FirstDayOfWeek="Monday" OnClientShown="DisableExceptMonday">
        </ajaxToolkit:CalendarExtender>     
  
    
    </form>
</body>
</html>


这篇关于如何禁用除星期一以外的日期到calendarextender C#的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-27 14:00