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?
1. Select a blank cell you will return the week number, enter this formula: =WEEKNUM(B1,1), and press the Enter key.
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.
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() + " -- ";
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With