using System ; using System.Web.UI ; using System.Web.UI.WebControls ; namespace WebApplication1 ... { /**//// <summary> /// WebForm1 的摘要说明。 /// </summary> public class WebForm1 : Page ...{ protected TextBox TextBox1 ; private void Page_Load ( object sender , EventArgs e ) ...{ this.TextBox1.Text = CalculateWorkingDays ( 2006 , 2 ).ToString ( ) ; } private int CalculateWorkingDays ( int Year , int Month ) ...{ int count = 0 ; DateTime [ ] sj = new DateTime[2] ; int ts = DateTime.DaysInMonth ( Year , Month ) ; sj [ 0 ] = DateTime.Parse ( Year + "-" + Month + "-1" ) ; sj [ 1 ] = DateTime.Parse ( Year + "-" + Month + "-" + ts ) ; for ( DateTime dtTemp = sj [ 0 ] ; dtTemp <= sj [ 1 ] ; dtTemp = dtTemp.AddDays ( 1 ) ) ...{ if ( ( dtTemp.DayOfWeek != DayOfWeek.Saturday ) && ( dtTemp.DayOfWeek != DayOfWeek.Sunday ) ) ...{ count++ ; } } return count ; } Web 窗体设计器生成的代码#region Web 窗体设计器生成的代码 protected override void OnInit ( EventArgs e ) ...{ // // CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。 // InitializeComponent ( ) ; base.OnInit ( e ) ; } /**//// <summary> /// 设计器支持所需的方法 - 不要使用代码编辑器修改 /// 此方法的内容。 /// </summary> private void InitializeComponent ( ) ...{ this.Load += new EventHandler ( this.Page_Load ) ; } #endregion }}