Using Calender Control in ASP .NET | Calender Control Tutorial
In this tutorial we will learn to use the calender control and display the selected dates in the calender control.
Let’s add a new form to our ASP .NET website and name it CalendexExample.aspx . See to it that you allow the addition of a code behind file. From the ToolBox in the sidebar of the IDE (Visual Studio 2013) find the Calender Control and drag and drop it to the design view.
If you are the code guy then feel free to add the following code to the code view of the page between the <div></div> tags.
We will be using the following controls for this simple example:
- Calender Control
- Button Control
- Bulleted List Control
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="CalenderExample.aspx.cs" Inherits="CalenderExample" %>
In the code behind file we will add the following code:
using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; public partial class CalenderExample : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { } protected void btnSubmit_Click(object sender, EventArgs e) { //assign the salected dates of the calender control //as the data source of the bulleted list. bltselectedDate.DataSource = Calendar1.SelectedDates; //Bind the data source to the bulleted list bltselectedDate.DataBind(); } }