Solved

Calendar Control

Posted on 2007-11-28
4
318 Views
Last Modified: 2012-06-27
This is not an exam or homework

The code snippet below shows a Calendar and a Label control added to a simple Web site. The selection mode is set to DayWeekMonth:

<asp:Calendar id="Calendar1" runat="server" DayNameFormat="Short" SelectionMode="DayWeekMonth">
</asp:Calendar>
<asp:Label id="Label1" runat="server"/>

Once a user makes a selection, you need to write code in the Calendar1 SelectionChanged event to evaluate if a user clicked on a day, week or month and write the result to Label1

Whick of the following code segments will acheve the stated goals?

1.
Select Case Calendar1.SelectedDates.Count
  Case 1 'Day
     Label1.Text="You have selected a day."
  Case 7 'Week
     Label1.Text="You have selected a week."
  Case is > 7
     Label1.Text="You have selected a month."
End Select

2.
Select Case Calendar1.SelectionMode
  Case "Day"
     Label1.Text="You have selected a day."
  Case "Week"
     Label1.Text="You have selected a week."
  Case "Month"
     Label1.Text="You have selected a month."
End Select

3.
Select Case Calendar1.Count
  Case 1 'Day
     Label1.Text="You have selected a day."
  Case 7 'Week
     Label1.Text="You have selected a week."
  Case Is > 7
     Label1.Text="You have selected a month."
End Select

4.

Select Case Calendar1.SelectedMode.Current
  Case "Day"
     Label1.Text="You have selected a day."
  Case "Week"
     Label1.Text="You have selected a week."
  Case "Month"
     Label1.Text="You have selected a month."
End Select
0
Comment
Question by:cybernation989
  • 2
  • 2
4 Comments
 
LVL 142

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 20364217
A quick glance at the properties of the calendar control will tell you the correct answer.

note: answer #2 is obviously wrong, I hope you see that..
0
 

Author Comment

by:cybernation989
ID: 20364343
Great example of code at http://msdn2.microsoft.com/en-us/library/dxf9k8sh(vs.71).aspx

I have to go with answer 1 but then again I have been wrong many of times.
VB
 

Sub Date_Selected(sender as Object sender, e As EventArgs)

   Select (Calendar1.SelectedDates.Count)

      Case 0:    'None

         Label1.Text = "No dates are currently selected"

      Case 1:    'Day

         Label1.Text = "The selected date is " & _ 

                       Calendar1.SelectedDate.ToShortDateString

      Case 7:    'Week

         Label1.Text = "The selection is a week beginning " & _

                       Calendar1.SelectedDate.ToShortDateString

      Case Else: 'Month

         Label1.Text = "The selection is a month beginning " & _

                       Calendar1.SelectedDate.ToShortDateString

   End Select

End Sub

Open in new window

0
 
LVL 142

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 500 total points
ID: 20364356
yes, that answer would be correct!
0
 

Author Comment

by:cybernation989
ID: 20364417
Hey I got one... hands angelIII a beer
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Lots of people ask this question on how to extend the “MembershipProvider” to make use of custom authentication like using existing database or make use of some other way of authentication. Many blogs show you how to extend the membership provider c…
Today is the age of broadband.  More and more people are going this route determined to experience the web and it’s multitude of services as quickly and painlessly as possible. Coupled with the move to broadband, people are experiencing the web via …
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now