zoukankan      html  css  js  c++  java
  • 【原创】.Net WebForm Calendar 日历控件常用方法

    微软官方地址 https://msdn.microsoft.com/en-us/library/add3s294.aspx

    1.设置日历控件单个日期Table Cell样式 颜色/外观/边距

    protected void Calendar1_DayRender(object sender, 
        DayRenderEventArgs e)
    {
        // Display vacation dates in yellow boxes with purple borders.
        Style vacationStyle = new Style();
        vacationStyle.BackColor = System.Drawing.Color.Yellow;
        vacationStyle.BorderColor = System.Drawing.Color.Purple;
        vacationStyle.BorderWidth = 3;
    
        // Display weekend dates in green boxes.
        Style weekendStyle = new Style();
        weekendStyle.BackColor = System.Drawing.Color.Green;
    
        if ((e.Day.Date >= new DateTime(2000,11,23)) &&
            (e.Day.Date <= new DateTime(2000,11,30)))
        {
            // Apply the vacation style to the vacation dates.
            e.Cell.ApplyStyle(vacationStyle);
        }
        else if (e.Day.IsWeekend)
        {
            // Apply the weekend style to the weekend dates.
            e.Cell.ApplyStyle(weekendStyle);
        }
    }

    2.设置特定日期不可见/不可选的方法

      protected void Calendar1_DayRender(object sender, System.Web.UI.WebControls.DayRenderEventArgs e)
            {
                if (e.Day.IsOtherMonth)
                {
                    Style visible = new Style();
                    visible.BackColor = System.Drawing.Color.White;
                    visible.BorderColor = System.Drawing.Color.White;
                    visible.ForeColor = Color.White;
                    e.Day.IsSelectable = false;
                    e.Cell.ApplyStyle(visible);
                    return;
                }
    }
    

     e.Day.IsSelectable = false;这句即是设置不可选择的方法

  • 相关阅读:
    java 重定向和转发的区别
    Python练习100则--部分概念的没有做
    MYSQL忘记root密码后如何修改
    二分查找注意点
    数据库连接串整理
    MYSQL mysqldump数据导出详解
    MVCC的一些理解
    MySQL 加锁处理分析-转载
    扩展1
    maven-windows使用
  • 原文地址:https://www.cnblogs.com/GundamPeter/p/9418158.html
Copyright © 2011-2022 走看看