clement
clement

Reputation: 4266

use DateTimePicker on aspx

I have a Form project that use DateTimePicker and I have to include those components into asp.net aspx webapp. So I'm trying to include a DateTime Picker on asp.net webform but I can't.

I'm not an expert with aspx so maybe it's really a simple question.

I only see calendar in toolbox but not DateTimePicker.

The one I want to use is

System.Windows.Forms.DateTimePicker

could it be possible to include it into asp.net project?

Upvotes: 0

Views: 1701

Answers (2)

Tchaps
Tchaps

Reputation: 874

Because it'is a web application i could just use JQuery UI http://jqueryui.com/datepicker/#inline

<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>jQuery UI Datepicker - Display inline</title>
<link rel="stylesheet" href="//code.jquery.com/ui/1.11.3/themes/smoothness/jquery-ui.css">
<script src="//code.jquery.com/jquery-1.10.2.js"></script>
<script src="//code.jquery.com/ui/1.11.3/jquery-ui.js"></script>
<link rel="stylesheet" href="/resources/demos/style.css">
<script>
$(function() {
   $( "#datepicker" ).datepicker();
});
</script>
</head>
<body>
<form runat="server" id="form1">
    Date: <div id="datepicker"></div>
</form>
</body>
</html>

Here is a full API description http://api.jqueryui.com/datepicker/ May be this can help you as an alternative to do this also !\

There is also an Ajax library for .NET. you can try also: http://www.codeproject.com/Tips/407460/How-to-use-ASP-NET-AJAX-Calender-Extender

Upvotes: 0

Mukesh Kini U
Mukesh Kini U

Reputation: 21

You can use something like below on the Calender Click Method:

DateTime date = Convert.ToDateTime(calendar.SelectedDate.ToString());

Here calendar is the ID of your calendar control!

Hope this helps.

Upvotes: 1

Related Questions