當前位置:成語大全網 - 書法字典 - 如何寫取當前日期所在季度的第壹天和最後壹天的函數?網?

如何寫取當前日期所在季度的第壹天和最後壹天的函數?網?

第壹種方案:要求我們在文本框中輸入妳想要的月份進行判斷。

頁面設計代碼:

& lt% @ Page Language = " c# " AutoEventWireup = " true " CodeFile = " Default . aspx . cs " Inherits = " website 1 _ Default " % & gt;

& lt!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN " " http://www . w3 . org/TR/XHTML 1/DTD/XHTML 1-Transitional . DTD " & gt;

& lthtml xmlns = " http://www . w3 . org/1999/XHTML " & gt;

& lthead runat = " server " & gt

& lttitle & gt沒有標題頁

& lt/head & gt;

& ltbody & gt

& ltform id = " form 1 " runat = " server " >

& ltdiv & gt

& ltASP:Label ID = " Label 1 " Runat = " server " text = "請輸入當前月份:" > & lt/ASP:Label & gt;

& ltASP:TextBox ID = " TextBox 1 " runat = " server " >& lt/ASP:TextBox & gt;

& ltASP:Button ID = " Button 1 " Runat = " Server " onclick = " Button 1 _ click " text = " Submit "/& gt;& ltbr/>;

& ltbr/>;

& ltASP:Label ID = " Label 2 " Runat = " server " text = "賽季的第壹天:" > & lt/ASP:Label & gt;

& ltASP:Label ID = " Label 3 " runat = " server " ForeColor = " # ff 0066 " >& lt/ASP:Label & gt;

& ltASP:label ID = " label 4 " runat = " server " text = "賽季的最後壹天:" > & lt/ASP:Label & gt;

& ltASP:Label ID = " Label 5 " runat = " server " ForeColor = " # 003399 " >& lt/ASP:Label & gt;& lt/div & gt;

& lt/form & gt;

& lt/body & gt;

& lt/html & gt;

頁面背景代碼:

使用系統;

使用系統。數據;

使用系統。配置;

使用系統。收藏;

使用系統。Web

使用系統。網絡安全;

使用系統。Web . UI

使用系統。Web . UI.WebControls

使用系統。web . ui . web controls . web parts;

使用系統。Web . UI.HtmlControls

使用系統。計時器;

公共分部類WebSite1_Default : System。網頁界面

{

受保護的void Page_Load(對象發送方,EventArgs e)

{

}

受保護的void Button1_Click(對象發送方,EventArgs e)

{

int月;

月份=轉換。ToInt32(TextBox1。正文);

//月球定律

if(month & gt;= 1。& amp月份& lt4)

{

label 3 . text = " 65438+10月1 ";

Label5。text = " 3 March 31 ";

}

else if(month & gt;= 4 & amp& amp月份& lt7)

{

標簽3。text = " 4 April 1 ";

Label5。Text = "6月30日";

}

else if(month & gt;= 7 & amp& amp月份& lt10)

{

標簽3。text = " 7 July 1 ";

Label5。Text = "9月30日";

}

其他

{

label 3 . text = " 65438+10月1 ";

label 5 . text = " 65438+二月31 ";

}

}

}

********************************************************************

使用系統;

使用系統。數據;

使用系統。配置;

使用系統。收藏;

使用系統。Web

使用系統。網絡安全;

使用系統。Web . UI

使用系統。Web . UI.WebControls

使用系統。web . ui . web controls . web parts;

使用系統。Web . UI.HtmlControls

使用系統。計時器;

公共分部類WebSite1_Default : System。網頁界面

{

受保護的void Page_Load(對象發送方,EventArgs e)

{

}

受保護的void Button1_Click(對象發送方,EventArgs e)

{

int月;

月份=轉換。ToInt32(TextBox1。正文);

//陽歷法

if(month & gt;= 3 & amp& amp月份& lt6)

{

標簽3。text = " 3 March 1 ";

Label5。text = " 5 May 31 ";

}

else if(month & gt;= 6 & amp& amp月份& lt9)

{

標簽3。text = " 6 June 1 ";

Label5。text = " 8 August 31 ";

}

else if(month & gt;= 9 & amp& amp月份& lt12)

{

標簽3。Text = "9月9日1 ";

Label5。text = " 11+10月30日";

}

其他

{

label 3 . text = " 65438+二月1 ";

Label5。Text = "2月28日";

}

}

}

方案二:要求根據電腦系統的時間和月份自動判斷!

頁面代碼

& lt% @ Page Language = " c# " AutoEventWireup = " true " CodeFile = " default 2 . aspx . cs " Inherits = " website 1 _ default 2 " % & gt;

& lt!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN " " http://www . w3 . org/TR/XHTML 1/DTD/XHTML 1-Transitional . DTD " & gt;

& lthtml xmlns = " http://www . w3 . org/1999/XHTML " & gt;

& lthead runat = " server " & gt

& lttitle & gt沒有標題頁

& lt/head & gt;

& ltbody & gt

& ltform id = " form 1 " runat = " server " >

& ltdiv & gt

& ltASP:Label ID = " Label 1 " runat = " server " >& lt/ASP:Label & gt;& ltbr/>;

& ltbr/>;

& ltASP:Label ID = " Label 2 " Runat = " server " text = "賽季的第壹天:" > & lt/ASP:Label & gt;

& ltASP:Label ID = " Label 3 " runat = " server " ForeColor = " # ff 0066 " >& lt/ASP:Label & gt;

& ltASP:label ID = " label 4 " runat = " server " text = "賽季的最後壹天:" > & lt/ASP:Label & gt;

& ltASP:Label ID = " Label 5 " runat = " server " ForeColor = " # 003399 " >& lt/ASP:Label & gt;& ltbr/>;

& ltbr/>;

& ltbr/>;

& lt/div & gt;

& lt/form & gt;

& lt/body & gt;

& lt/html & gt;

-

背景代碼:

使用系統;

使用系統。數據;

使用系統。配置;

使用系統。收藏;

使用系統。Web

使用系統。網絡安全;

使用系統。Web . UI

使用系統。Web . UI.WebControls

使用系統。web . ui . web controls . web parts;

使用系統。Web . UI.HtmlControls

公共分部類WebSite1_Default2 : System。網頁界面

{

受保護的void Page_Load(對象發送方,EventArgs e)

{

int月;

月=系統。日期時間.現在.月份;

Label1。Text = "當前月份(根據陽歷算法)是"+月+"月";

//陽歷法

if(month & gt;= 3 & amp& amp月份& lt6)

{

標簽3。text = " 3 March 1 ";

Label5。text = " 5 May 31 ";

}

else if(month & gt;= 6 & amp& amp月份& lt9)

{

標簽3。text = " 6 June 1 ";

Label5。text = " 8 August 31 ";

}

else if(month & gt;= 9 & amp& amp月份& lt12)

{

標簽3。Text = "9月9日1 ";

Label5。text = " 11+10月30日";

}

其他

{

label 3 . text = " 65438+二月1 ";

Label5。Text = "2月28日";

}

}

}

如果樓主覺得我辛苦,我可以多拿點!嗯。多有趣啊