Click here to Skip to main content
15,897,182 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,
i need a datepicker in the click of textbox.


Now i have written the following code:

In html:

XML
<link href="@Url.Content("~/Content/themes/base/jquery.ui.all.css")" rel="stylesheet" type="text/css" />
    <link href="@Url.Content("~/Content/themes/base/jquery.ui.css")" rel="stylesheet" type="text/css" />
    <script src="../../Scripts/jquery-1.7.1.js" type="text/javascript"></script>
    <script src="../../Scripts/jquery-1.7.1.min.js"type="text/javascript"></script>
    <script src="../../Scripts/jquery-ui-1.8.20.js" type="text/javascript"></script>
    <script src="../../Scripts/jquery-ui-1.8.20.min.js" type="text/javascript"></script>


<td><input type="text" id="datepicker" /></td>


In knockout.js:
$(function () { $("#datepicker").datepicker(); });



But it is not working please guide me to do this.

Thank You
Posted
Updated 20-Aug-13 20:44pm
v3
Comments
Jameel VM 21-Aug-13 3:04am    
why u are using knock out js for this?
Jameel VM 21-Aug-13 3:06am    
please check the error in console.
Minnu Sanju 21-Aug-13 3:07am    
in my application i am using knockout.js
so i wrote the script for datepicker also in it
Minnu Sanju 21-Aug-13 3:09am    
i am using knockout.js in my application so i wrote the datepicker script also in it
Jameel VM 21-Aug-13 3:13am    
for displaying a simple datepicker control why you are using knockoutjs?

Problems

1. You have included the jQuery files two times. Remove one.
HTML
<script src="../../Scripts/jquery-1.7.1.js" type="text/javascript"></script>
<script src="../../Scripts/jquery-1.7.1.min.js"type="text/javascript"></script>


2. You have included jQuery UI js two times. Remove one.
HTML
<script src="../../Scripts/jquery-ui-1.8.20.js" type="text/javascript"></script>
<script src="../../Scripts/jquery-ui-1.8.20.min.js" type="text/javascript"></script>


3. You have included jQuery UI css two times. Remove one.
HTML
<link href="@Url.Content("~/Content/themes/base/jquery.ui.all.css")" rel="stylesheet" type="text/css" />
<link href="@Url.Content("~/Content/themes/base/jquery.ui.css")" rel="stylesheet" type="text/css" />


Solution

Refer - Datepicker[^]
Check what are the files included and how it is working. Try like below...
XML
<!doctype html>

<html lang="en">
<head>
  <meta charset="utf-8" />
  <title>jQuery UI Datepicker - Default functionality</title>
  <link rel="stylesheet" href="http://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css" />
  <script src="http://code.jquery.com/jquery-1.9.1.js"></script>
  <script src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script>
  <link rel="stylesheet" href="/resources/demos/style.css" />
  <script>
  $(function() {
    $( "#datepicker" ).datepicker();
  });
  </script>
</head>
<body>

<p>Date: <input type="text" id="datepicker" /></p>


</body>
</html>
 
Share this answer
 
v3
 
Share this answer
 
Comments
Minnu Sanju 21-Aug-13 4:09am    
i have tried this. Problem is that i when i use this in a view page it works. But i need the date picker in a partial view whick comes as popup.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900