This tutorial will demonstrate how to use the calendar control with ASP.NET 4.0 and C#.
Adding the Default.aspx Page
To work with the calendar control we will be creating a simple web page that will contain a label and a calendar. At this point I have created a new ASP.NET Empty Web Site. Next, we need to:
Working with the Calendar
Now that we have our simple form setup we can begin working with the calendar. The calendar allows you to select dates and even has some custom events to tell when the user is working with the calendar control. Here we will simply demonstrate how to determine which date has been selected by the user in the event that the selected date on the calendar has been changed. To begin, open up Default.aspx to design mode and:
Yes, it is possible to find a good web host. Sometimes it takes a while to find one you are comfortable with. After trying several, we went with Server Intellect and have been very happy thus far. They are by far the most professional, customer service friendly and technically knowledgeable host we've found so far.
Testing
To test this out and ensure that it is working properly, load up the web site and select a date in the calendar. The page should do a complete postback and load with the currently selected date in the label.
To work with the calendar control we will be creating a simple web page that will contain a label and a calendar. At this point I have created a new ASP.NET Empty Web Site. Next, we need to:
- Right click the project in your solution explorer.
- Select add new item...
- Select a web form.
- Name it 'Default.aspx'.
- Click add.
- Open Default.aspx up to design mode.
- Drag and drop a label onto the web form.
- Add in a break line under the label.
- Drag and drop a calendar underneath the label.
Working with the Calendar
Now that we have our simple form setup we can begin working with the calendar. The calendar allows you to select dates and even has some custom events to tell when the user is working with the calendar control. Here we will simply demonstrate how to determine which date has been selected by the user in the event that the selected date on the calendar has been changed. To begin, open up Default.aspx to design mode and:
- Double click the calendar to generate the Calendar1_SelectionChanged event method.
- Add the following code to the Calendar1_SelectionChanged event method:
protected void Calendar1_SelectionChanged(object sender, EventArgs e)
{
//display the selected date of the calendar
Label1.Text = Calendar1.SelectedDate.ToString();
}
Yes, it is possible to find a good web host. Sometimes it takes a while to find one you are comfortable with. After trying several, we went with Server Intellect and have been very happy thus far. They are by far the most professional, customer service friendly and technically knowledgeable host we've found so far.
Testing
To test this out and ensure that it is working properly, load up the web site and select a date in the calendar. The page should do a complete postback and load with the currently selected date in the label.
No comments:
Post a Comment