Solved

Calendar Control

Posted on 2007-11-28
4
323 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 143

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 143

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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Object Oriented Programming, C#, referencing, scoping. 13 86
IEnumerable<T> to a List<T> 8 53
Data organization issue 7 37
Record locking on classic ASP 3 40
I have developed many web applications with asp & asp.net and to add and use a dropdownlist was always a very simple task, but with the new asp.net, setting the value is a bit tricky and its not similar to the old traditional method. So in this a…
Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

733 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