JavaScript calendar date picker for ASP NET04:33

  • 0
Published on March 26, 2017

Link for all dot net and sql server video tutorial playlists

Link for slides, code samples and text version of the video

In this video we will discuss how to include a JavaScript calendar date picker on ASP.NET page.

There are several free JavaScript calendar date pickers available on the internet. Just search the internet for free JavaScript calendar date picker for ASP.NET.

Pikaday is one of the JavaScript calendar date picker. Below is the URL to download.

Here are the steps to include Pikaday JavaScript calendar date picker on ASP.NET webform
1. Extract the contents of the downloaded folder.

2. Copy and paste the following folder and js file in your asp.net project. Copy them to the root directory of your web application.
css
pikaday.js

3. On the webform, include references to the following 3 css stylesheets. Also include reference to pikaday.js JavaScript file.
pikaday.css
site.css
theme.css

4. Drag and drop a TextBox control on the webform

5. Include the following script element on the webform
[script type=”text/javascript”]
var picker = new Pikaday(
{
field: document.getElementById(‘TextBox1’),
firstDay: 1,
minDate: new Date(‘2000-01-01’),
maxDate: new Date(‘2020-12-31’),
yearRange: [2000, 2020],
numberOfMonths: 3,
theme: ‘dark-theme’
});
[/script]

At this point, your webform should look as shown below.

[%@ Page Language=”C#” AutoEventWireup=”true” CodeBehind=”WebForm1.aspx.cs” Inherits=”Demo.WebForm1″ %]
[!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN” ”
[html xmlns=”
[head runat=”server”]
[title][/title]
[link href=”css/pikaday.css” rel=”stylesheet” type=”text/css” /]
[link href=”css/theme.css” rel=”stylesheet” type=”text/css” /]
[link href=”css/site.css” rel=”stylesheet” type=”text/css” /]
[script src=”pikaday.js” type=”text/javascript”][/script]
[/head]
[body]
[form id=”form1″ runat=”server”]
[asp:TextBox ID=”TextBox1″ runat=”server”][/asp:TextBox]
[script type=”text/javascript”]
var picker = new Pikaday(
{
field: document.getElementById(‘TextBox1’),
firstDay: 1,
minDate: new Date(‘2000-01-01’),
maxDate: new Date(‘2020-12-31’),
yearRange: [2000, 2020],
numberOfMonths: 3,
theme: ‘dark-theme’
});
[/script]
[/form]
[/body]
[/html]

Enjoyed this video?
"No Thanks. Please Close This Box!"