How To Use Calendar Control in Asp.Net
Today in this tutorial we will learn how to use Calendar Control in Asp.Net. You can use a calendar to select a particular date. Basically there are two ways to use calendar control in Asp.Net :
- Calendar Control using Standard Tools.
- Using Caledar Extendar from Ajax Control Toolkit
Here I am showing you both the ways. So lets start the tutorial.
Calendar using Standard Calendar Control ::
Step 1 ::
First you need to fetch four control from the toolbox three from Standard Toolbox and one from Ajax Control Toolkit.
Goto Toolbox > Standard Tools > Calendar // Calendar1
Goto Toolbox > Standard Tools > TextBox // TextBox1
Goto Toolbox > Standard Tools > TextBox // TextBox2
Goto Toolbox > Ajax Control Toolkit > ToolScriptManager
if you don't have Ajax Controls then you can install it by following the link given below.
You might also like this :: How To Add Ajax Control Toolkit To Visual Studio
Step 2 ::
After following the above' steps generat the Calendar' SelectionChanged event (Calendar1_SelectionChanged) and write a one line code.
protected void Calendar1_SelectionChanged(object sender, EventArgs e)
{
TextBox1.Text = "Selected Date Is :" + Calendar1.SelectedDate;
}
this will show the selected date into the TextBox1.
You might also like this :: How to use Balloon Popup Extendar in Asp.Net
Step 3 ::
Now save all the things and view page in Browser.
Now you can see that when you click on any date it will shown into the TextBox1. So you have done with simple calendar control using Standard Tools.
Calendar using Calendar Extendar from Ajax Controls ::
This the second way to use the Caledar in Asp.Net. In this, you will learn how to display a popup calendar whetn someone move focus to a textbox.
For this you need three things that we already fetched from the toolbox i.e.
- TextBox
- ToolScriptManager
- CalendarExtendar
Step 1 ::
Now goto the Smart Menu of Textbox2 and click on the add extendar
You might also like this :: How to Use Popup Control in Asp.Net
Step 2 ::
When you click on the add extendar a window will open, now what you have to do, select Calendar Extendar from that window and clikc on OK button.
Step 3 ::
Now see the page in Browser, you will see that when you move focus to the TextBox2 a calendar will popped up.
From the Editor’s Desk
Finally you have done with both the ways to use the Calendar Control in asp.net. hope this will help you to increase you programming skills.
Thank you for giving your time.
How To Use Calendar Control in Asp.Net
Reviewed by Team tt24
on
9:54 PM
Rating:
No comments: