Calendar extender - Day of year - Day of week
Hello,
I am trying to verify what day of the year has been selected from the calendar extender in asp.net.
I know that in vb.net for example I would verify if the day selected is after the 121st day of the year, the syntax would be:
Code:
If DateTimePickerCheckIn.Value.DayOfYear >= 121
Then some code...
It seems that value is not accepted after the declaration of the calendar extender.
I'm also trying to figure out how to know if the day is Friday.
For example, in VB.NET, the syntax would be :
Code:
checkInDate.Value.DayOfWeek = DayOfWeek.Friday
It seems I can not find any documentation on this subject.
Thank you in advance!
Marie
Re: Calendar extender - Day of year - Day of week
A quick web search shows that it doesn't have a Value property, but it does have a SelectedDate property. Does that work for you?
Re: Calendar extender - Day of year - Day of week
Yes, that make sens.
So since the selected date as a type of date, I am assuming that I need to convert the selected date to an integer to find out the day of the year and to a string to find the day of the week.
I tried to do so with a simple calendar extender, a button and 2 text boxes to show the values:
Code:
Public Class Reservation1
Inherits System.Web.UI.Page
Dim DayOfYear As Integer
Dim dayOfWeek As String
Protected Sub ButtonCalculate_Click(sender As Object, e As EventArgs) Handles ButtonCalculate.Click
DayOfYear = Convert.ToInt32(checkInDate.SelectedDate)
dayOfWeek = checkInDate.SelectedDate.ToString()
TextBoxDayOfYear.Text = DayOfYear.ToString()
TextBoxDayOfWeek.Text = dayOfWeek.ToString()
End Sub
End Class
I don't think it's the way to convert my selected date. It seems it's not returning anything. Any ideas?
Re: Calendar extender - Day of year - Day of week
The .Value property of a DateTimePicker also returns a Date, so you should be able to use the same properties etc that you did with that, eg:
Code:
TextBoxDayOfYear.Text = checkInDate.SelectedDate.DayOfYear.ToString()
TextBoxDayOfWeek.Text = checkInDate.SelectedDate.DayOfWeek.ToString()
Attempting to convert the Date itself to an Integer or String wouldn't help you with either of these things.