Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Week Dates on week number click

Is there any way in asp.net or using javascript that when someone clicks on the week number shown on the calendar and I can get the dates (Monday to Friday) on a label?

like image 432
SPandya Avatar asked Jan 06 '14 04:01

SPandya


People also ask

How do I automate the week number in Excel?

1. Select a blank cell you will return the week number, enter this formula: =WEEKNUM(B1,1), and press the Enter key.

What is the difference between ISOWeekNum and Weeknum?

WeekNum uses the week containing January 1 as the first week of the year. The result from this function can range from 1 to 54. ISOWeekNum uses the week containing the first Thursday of the year as the first week of the year. This follows the ISO 8601 date and time standard definition for week numbering.


1 Answers

Here is a server side solution in asp.net

Markup

<asp:Label ID="Label1" runat="server" Text="" />
<asp:Calendar runat="server" ID="Calendar1" OnSelectionChanged="Calendar1_SelectionChanged" />

Code Behind

protected void Calendar1_SelectionChanged(object sender, EventArgs e)
{
    DateTime input = Calendar1.SelectedDate;
    int delta = DayOfWeek.Sunday - input.DayOfWeek;
    DateTime firstDay = input.AddDays(delta);

    for (int i = 0; i < 7; i++)
      Label1.Text += ((DateTime)(firstDay.Add(new TimeSpan(i, 0, 0, 0)))).ToShortDateString() + " -- ";
}
like image 107
Bradley Gatewood Avatar answered Oct 03 '22 14:10

Bradley Gatewood