?
Solved

Calendar Control

Posted on 2007-11-28
4
Medium Priority
?
327 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 2000 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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

In .NET 2.0, Microsoft introduced the Web Site.  This was the default way to create a web Project in Visual Studio 2005.  In Visual Studio 2008, the Web Application has been restored as the default web Project in Visual Studio/.NET 3.x The Web Si…
A quick way to get a menu to work on our website, is using the Menu control and assign it to a web.sitemap using SiteMapDataSource. Example of web.sitemap file: (CODE) Sample code to add to the page menu: (CODE) Running the application, we wi…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses

770 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