判断年月日的方法
1.
2.
3.
1 protected string getChangeDay(string month,int year) 2 { 3 if ((month == "01") || (month == "03") || (month == "05") || (month == "07") || (month == "08") || (month == "10") || (month == "12")) 4 { 5 return "31"; 6 } 7 else if (month == "02") 8 { 9 if (year % 4 == 0 && year % 100 != 0 || year % 400 == 0) 10 { 11 return "28"; 12 } 13 else { return "29"; } 14 } 15 else 16 { 17 return "30"; 18 } 19 } 20 protected void ddlYear_SelectedIndexChanged(object sender, EventArgs e) 21 { 22 getChage(); 23 } 24 25 private void getChage() 26 { 28 txtCreator.Value = string.Empty; 29 string year = ddlYear.SelectedValue; 30 string month = ddlMonth.SelectedValue; 31 if (!string.IsNullOrEmpty(year)) 32 { 33 txtStartDate.Text = year + "-" + month + "-" + "01"; 34 txtEndDate.Text = year + "-" + month + "-" + getChangeDay(month, Convert.ToInt32(year)); 35 } 37 } 38 protected void ddlMonth_SelectedIndexChanged(object sender, EventArgs e) 39 { 40 getChage(); 41 }