First of all add the following NameSpace in your .aspx.cs File
using System.Globalization;
protected void Page_Load(object sender, EventArgs e)
{
DateTime currentDateTime=System.DateTime.Now;
int year=currentDateTime.Year;
int months=currentDateTime.Month;
GetDatesOfSundays(year, months, DayOfWeek.Sunday);
}
protected void GetDatesOfSundays(int year, int month, DayOfWeek dayName)
{
CultureInfo ci = new CultureInfo("en-US");
for (int i = 1; i <= ci.Calendar.GetDaysInMonth(year, month); i++)
{
if (new DateTime(year, month, i).DayOfWeek == dayName)
Response.Write(i.ToString() + ",");
}
}
using System.Globalization;
protected void Page_Load(object sender, EventArgs e)
{
DateTime currentDateTime=System.DateTime.Now;
int year=currentDateTime.Year;
int months=currentDateTime.Month;
GetDatesOfSundays(year, months, DayOfWeek.Sunday);
}
protected void GetDatesOfSundays(int year, int month, DayOfWeek dayName)
{
CultureInfo ci = new CultureInfo("en-US");
for (int i = 1; i <= ci.Calendar.GetDaysInMonth(year, month); i++)
{
if (new DateTime(year, month, i).DayOfWeek == dayName)
Response.Write(i.ToString() + ",");
}
}
No comments:
Post a Comment