直接上代码,不多说别的了

<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:DropDownList ID="DropDownListYear" runat="server" AutoPostBack="True" OnSelectedIndexChanged="DropDownListYear_SelectedIndexChanged">
<asp:ListItem Value=""></asp:ListItem>
<asp:ListItem Value=""></asp:ListItem>
<asp:ListItem Value=""></asp:ListItem>
<asp:ListItem Value=""></asp:ListItem>
<asp:ListItem Value=""></asp:ListItem>
<asp:ListItem Value=""></asp:ListItem>
<asp:ListItem Value=""></asp:ListItem>
<asp:ListItem Value=""></asp:ListItem>
<asp:ListItem Value=""></asp:ListItem>
<asp:ListItem Value=""></asp:ListItem>
<asp:ListItem Value=""></asp:ListItem>
<asp:ListItem Value=""></asp:ListItem>
<asp:ListItem Value=""></asp:ListItem>
<asp:ListItem Value=""></asp:ListItem>
<asp:ListItem Value=""></asp:ListItem>
<asp:ListItem Value=""></asp:ListItem>
<asp:ListItem Value=""></asp:ListItem>
<asp:ListItem Value=""></asp:ListItem>
<asp:ListItem Value=""></asp:ListItem>
<asp:ListItem Value=""></asp:ListItem>
<asp:ListItem Value=""></asp:ListItem>
<asp:ListItem Value=""></asp:ListItem>
<asp:ListItem Value=""></asp:ListItem>
<asp:ListItem Value=""></asp:ListItem>
<asp:ListItem Value=""></asp:ListItem>
<asp:ListItem Value=""></asp:ListItem>
<asp:ListItem Value=""></asp:ListItem>
<asp:ListItem Value=""></asp:ListItem>
<asp:ListItem Value=""></asp:ListItem>
<asp:ListItem Value=""></asp:ListItem>
<asp:ListItem Value=""></asp:ListItem>
<asp:ListItem Value=""></asp:ListItem>
<asp:ListItem Value=""></asp:ListItem>
<asp:ListItem Value=""></asp:ListItem>
<asp:ListItem Value=""></asp:ListItem>
<asp:ListItem Value=""></asp:ListItem>
<asp:ListItem Value=""></asp:ListItem>
<asp:ListItem Value=""></asp:ListItem>
<asp:ListItem Value=""></asp:ListItem>
<asp:ListItem Value=""></asp:ListItem>
<asp:ListItem Value=""></asp:ListItem>
<asp:ListItem Value=""></asp:ListItem>
<asp:ListItem Value=""></asp:ListItem>
<asp:ListItem Value=""></asp:ListItem>
<asp:ListItem Value=""></asp:ListItem>
<asp:ListItem Value=""></asp:ListItem>
<asp:ListItem Value=""></asp:ListItem>
<asp:ListItem Value=""></asp:ListItem>
<asp:ListItem Value=""></asp:ListItem>
<asp:ListItem Value=""></asp:ListItem>
<asp:ListItem Value=""></asp:ListItem>
<asp:ListItem Value=""></asp:ListItem>
<asp:ListItem Value=""></asp:ListItem>
<asp:ListItem Value=""></asp:ListItem>
<asp:ListItem Value=""></asp:ListItem>
<asp:ListItem Value=""></asp:ListItem>
<asp:ListItem Value=""></asp:ListItem>
<asp:ListItem Value=""></asp:ListItem>
<asp:ListItem Value=""></asp:ListItem>
<asp:ListItem Value=""></asp:ListItem>
<asp:ListItem Value=""></asp:ListItem>
<asp:ListItem Value=""></asp:ListItem>
<asp:ListItem Value=""></asp:ListItem>
<asp:ListItem Value=""></asp:ListItem>
<asp:ListItem Value=""></asp:ListItem>
<asp:ListItem Value=""></asp:ListItem>
<asp:ListItem Value=""></asp:ListItem>
<asp:ListItem Value=""></asp:ListItem>
<asp:ListItem Value=""></asp:ListItem>
<asp:ListItem Value=""></asp:ListItem>
<asp:ListItem Value=""></asp:ListItem>
<asp:ListItem Value=""></asp:ListItem>
<asp:ListItem Value=""></asp:ListItem>
<asp:ListItem Value=""></asp:ListItem>
<asp:ListItem Value=""></asp:ListItem>
<asp:ListItem Value=""></asp:ListItem>
<asp:ListItem Value=""></asp:ListItem>
<asp:ListItem Value=""></asp:ListItem>
<asp:ListItem Value=""></asp:ListItem>
<asp:ListItem Value=""></asp:ListItem>
<asp:ListItem Value=""></asp:ListItem>
<asp:ListItem Value=""></asp:ListItem>
<asp:ListItem Value=""></asp:ListItem>
<asp:ListItem Value=""></asp:ListItem>
<asp:ListItem Value=""></asp:ListItem>
<asp:ListItem Value=""></asp:ListItem>
<asp:ListItem Value=""></asp:ListItem>
<asp:ListItem Value=""></asp:ListItem>
<asp:ListItem Value=""></asp:ListItem>
<asp:ListItem Value=""></asp:ListItem>
<asp:ListItem Value=""></asp:ListItem>
<asp:ListItem Value=""></asp:ListItem>
<asp:ListItem Value=""></asp:ListItem>
<asp:ListItem Value=""></asp:ListItem>
</asp:DropDownList>

<asp:DropDownList ID="DropDownListMonth" runat="server" AutoPostBack="True" OnSelectedIndexChanged="DropDownListMonth_SelectedIndexChanged">
<asp:ListItem Value=""></asp:ListItem>
<asp:ListItem Value=""></asp:ListItem>
<asp:ListItem Value=""></asp:ListItem>
<asp:ListItem Value=""></asp:ListItem>
<asp:ListItem Value=""></asp:ListItem>
<asp:ListItem Value=""></asp:ListItem>
<asp:ListItem Value=""></asp:ListItem>
<asp:ListItem Value=""></asp:ListItem>
<asp:ListItem Value=""></asp:ListItem>
<asp:ListItem Value=""></asp:ListItem>
<asp:ListItem Value=""></asp:ListItem>
<asp:ListItem Value=""></asp:ListItem>
</asp:DropDownList>

<asp:DropDownList ID="DropDownListDay" runat="server">
<asp:ListItem Value=""></asp:ListItem>
<asp:ListItem Value=""></asp:ListItem>
<asp:ListItem Value=""></asp:ListItem>
<asp:ListItem Value=""></asp:ListItem>
<asp:ListItem Value=""></asp:ListItem>
<asp:ListItem Value=""></asp:ListItem>
<asp:ListItem Value=""></asp:ListItem>
<asp:ListItem Value=""></asp:ListItem>
<asp:ListItem Value=""></asp:ListItem>
<asp:ListItem Value=""></asp:ListItem>
<asp:ListItem Value=""></asp:ListItem>
<asp:ListItem Value=""></asp:ListItem>
<asp:ListItem Value=""></asp:ListItem>
<asp:ListItem Value=""></asp:ListItem>
<asp:ListItem Value=""></asp:ListItem>
<asp:ListItem Value=""></asp:ListItem>
<asp:ListItem Value=""></asp:ListItem>
<asp:ListItem Value=""></asp:ListItem>
<asp:ListItem Value=""></asp:ListItem>
<asp:ListItem Value=""></asp:ListItem>
<asp:ListItem Value=""></asp:ListItem>
<asp:ListItem Value=""></asp:ListItem>
<asp:ListItem Value=""></asp:ListItem>
<asp:ListItem Value=""></asp:ListItem>
<asp:ListItem Value=""></asp:ListItem>
<asp:ListItem Value=""></asp:ListItem>
<asp:ListItem Value=""></asp:ListItem>
<asp:ListItem Value=""></asp:ListItem>
<asp:ListItem Value=""></asp:ListItem>
<asp:ListItem Value=""></asp:ListItem>
<asp:ListItem Value=""></asp:ListItem>
</asp:DropDownList>

</ContentTemplate>
</asp:UpdatePanel>
protected void DropDownListYear_SelectedIndexChanged(object sender, EventArgs e)
        {
            DropDownListDay.SelectedIndex = 0;
        }         protected void DropDownListMonth_SelectedIndexChanged(object sender, EventArgs e)
        {
            switch (DropDownListMonth.SelectedValue)
            {
                case "1":
                case "3":
                case "5":
                case "7":
                case "8":
                case "10":
                case "12":
                    DropDownListDay.Items.Clear();
                    for (int i = 1; i <= 31; i++)
                    {
                        DropDownListDay.Items.Add(new ListItem(Convert.ToString(i), Convert.ToString(i)));
                    }
                    break;
                case "4":
                case "6":
                case "9":
                case "11":
                    DropDownListDay.Items.Clear();
                    for (int i = 1; i <= 30; i++)
                    {
                        DropDownListDay.Items.Add(new ListItem(Convert.ToString(i), Convert.ToString(i)));
                    }
                    break;
                case "2":
                    DropDownListDay.Items.Clear();
                    if ((Convert.ToInt32(DropDownListYear.SelectedValue) % 4 == 0) || (Convert.ToInt32(DropDownListYear.SelectedValue) % 100 == 0))
                    {
                        for (int i = 1; i <= 29; i++)
                        {
                            DropDownListDay.Items.Add(new ListItem(Convert.ToString(i), Convert.ToString(i)));
                        };
                    }
                    else
                    {
                        for (int i = 1; i <= 28; i++)
                        {
                            DropDownListDay.Items.Add(new ListItem(Convert.ToString(i), Convert.ToString(i)));
                        };
                    }
                    break; 
            }
        }

代码直接贴入就可以运行,没什么技术含量不多做说明,如果觉得年份太多可以自己放到xml文件中!

ASP.NET实现年月日三级联动(局部刷新)的更多相关文章

  1. ASP.NET实现省市区三级联动(局部刷新)

    跟前一篇ASP.NET实现年月日三级联动(局部刷新)一样,没什么技术含量,直接上代码 <asp:ScriptManager ID="ScriptManager1" runat ...

  2. 利用select实现年月日三级联动的日期选择效果

    × 目录 [1]演示 [2]规划 [3]结构生成[4]算法处理 前面的话 关于select控件,可能年月日三级联动的日期选择效果是最常见的应用了.本文是选择框脚本的实践,下面将对日期选择效果进行详细介 ...

  3. JS年月日三级联动下拉框日期选择代码

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...

  4. JS 实现的年月日三级联动

    js文件 SYT="-请选择年份-"; SMT="-请选择月份-"; SDT="-请选择日期-"; BYN=50;//年份范围往前50年 A ...

  5. 时间操作(JavaScript版)—年月日三级联动(默认显示系统时间)

    版权声明:本文为博主原创文章,未经博主同意不得转载. https://blog.csdn.net/wangshuxuncom/article/details/35263317         这个功能 ...

  6. JS实现年月日三级联动+省市区三级联动+国家省市三级联动

    开篇随笔:最近项目需要用到关于年月日三级联动以及省市区三级联动下拉选择的功能,于是乎网上搜了一些做法,觉得有一些只是给出了小的案例或者只有单纯的js还不完整,却很难找到详细的具体数据(baidu搜索都 ...

  7. MVC三级联动无刷新

    本篇实现有关客户.订单和产品的无刷新三级联动,先看最终效果: 没有选择时,后2个Select状态为禁用: 当选择第1个Select,第2个Select可供选择,第3个Select依旧禁用: 当选择第2 ...

  8. js实现年月日三级联动

    当我们注册一个qq的时候,会看到一个三级年月日的联动菜单,下面简单介绍. <!doctype html> <html lang="en"> <head ...

  9. asp.net mvc3 利用Ajax实现局部刷新

    1.利用Ajax.ActionLink()方法 首先在_Layout.cshtml文件中加载 运行AJAX必要的Jquery <script src="@Url.Content(&qu ...

随机推荐

  1. JS笔记1

    1.每个函数对象都有一个length属性,表示该函数期望接收的参数个数.它与函数的arguments不同,arguments.length表示函数实际接收的参数个数. 2.javascript 中有五 ...

  2. 通过 Xshell 5 连接 centOS 7 服务器

    一. 在安装好了centOS 7 的服务上,打开终端 运行 ip -s addr 命令 获取服务的IP地址 [root@localhost ~]# ip -s addr1: lo: <LOOPB ...

  3. map 和 reduce

    注意:reduce需要 from functools import reduce map的使用: >>> def func(x): ... return x*x ... >&g ...

  4. 转: 如何用linux命令修改linux主机ip网关子网掩码

    linux一般使用ifconfig命令修改linux主机的ip.网关或子网掩码. 1.命令格式: ifconfig [网络设备] [参数] 2.命令功能: ifconfig 命令用来查看和配置网络设备 ...

  5. ES Head is not working with elasticsearch-1.4.0.Beta1

    ES Head is not working with elasticsearch-1.4.0.Beta1: https://github.com/elastic/elasticsearch/issu ...

  6. Android Service 简介

    Service是Android系统中的一种组件,它跟Activity的级别差不多,但是它不能自己运行,只能后台运行,并且可以和其他组件进行交互.Service是没有界面的长生命周期的代码.Servic ...

  7. Keil C51里面lib文件生成和调用方法

    一.包含关系 LCD1602.C里面包含LCD1602.H LCD1602.H的文件格式 二.设置生成lib文件 三.Lib文件调用 添加lib文件对话框 添加后的lib文件 呵呵^_^,这样就可以删 ...

  8. 使用MFC开发有十多年了,结合自身的体会,随便说几句(不能样样都依赖别人,C体系的人,绝对不怕人踢馆)

    挺长时间了吧,这个帖子还没沉下去,使用MFC开发有十多年了,结合自身的体会,随便说几句:1.MFC是一个C++的基础类库,封装了绝大多数的API函数,主要是用来创建带UI的应用程序,服务端程序或着不带 ...

  9. 14.4.2 Change Buffer 延迟写

    14.4.2 Change Buffer change buffer 是一个特殊的数据结构 用于cahce 改变的secondary index pages 当被影响的pages 不在buffer p ...

  10. jquery validate 自定义验证方法 日期验证

    jquery validate有很多验证规则,但是更多的时候,需要根据特定的情况进行自定义验证规则. 这里就来聊一聊jquery validate的自定义验证. jquery validate有一个方 ...