Solved

Calendar Control

Posted on 2007-11-28
4
321 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Visual Studio: built-in keystroke automation 2 47
Class object 2 26
Error in JQuery 5 38
Code works but it's slow 24 40
In this Article, I will provide a few tips in problem and solution manner. Opening an ASPX page in Visual studio 2003 is very slow. To make it fast, please do follow below steps:   Open the Solution/Project. Right click the ASPX file to b…
Sometimes in DotNetNuke module development you want to swap controls within the same module definition.  In doing this DNN (somewhat annoyingly) swaps the Skin and Container definitions to the default admin selections.  To get around this you need t…
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…

910 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

22 Experts available now in Live!

Get 1:1 Help Now