locked
** question added ** Differentiate DOW between time span (using two Calendar controls)? Please help! RRS feed

  • Question

  • User1389508859 posted

    I am using the Calendar control in asp.net to determine the arrival/departure dates on a form. I'd like to be able to tell what day of the week was selected in addition to the date. How would this be done? I have never used this control before and can't seem to find a good help document online. FYI, code-behind is in c#.

    Thank you.

    Saturday, November 16, 2013 2:18 PM

Answers

  • User2103319870 posted

    Hi,

    You can use Calendar SelectedDate property to get name of selected day

    Try using the below code to get day names of selected date in calendar

    Calendar1.SelectedDate.DayOfWeek

    Sample Code

    //Get the selected day name from calendar control
                string selectedDayname = Calendar1.SelectedDate.DayOfWeek.ToString();

    Html MarkUp:

     <asp:Calendar ID="Calendar1" runat="server"></asp:Calendar>


    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Saturday, November 16, 2013 2:26 PM

All replies

  • User2103319870 posted

    Hi,

    You can use Calendar SelectedDate property to get name of selected day

    Try using the below code to get day names of selected date in calendar

    Calendar1.SelectedDate.DayOfWeek

    Sample Code

    //Get the selected day name from calendar control
                string selectedDayname = Calendar1.SelectedDate.DayOfWeek.ToString();

    Html MarkUp:

     <asp:Calendar ID="Calendar1" runat="server"></asp:Calendar>


    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Saturday, November 16, 2013 2:26 PM
  • User1389508859 posted

    Simple enough! I suppose I would have seen that it I would have began the code.

    Thanks for the quick reply.

    Saturday, November 16, 2013 2:34 PM
  • User1389508859 posted

    I can't really move on until I figure this out. Hopefully someone can help me or this day will be wasted.

    In relation to this - let's say the user is staying for 5 days, Thursday-Monday. I referred to an old program of mine to calculate the days of stay, but let's say there is a different rate between weekdays and weekends - Is there a way to differentiate between the two within that 5 day range?

    Saturday, November 16, 2013 7:30 PM