Click here to Skip to main content
15,913,722 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
i've a javascript pop up calender and a text box, when ever user selects a date, it has to sit on the text box in the format which user has set for his computer, how can i achieve it?

What I have tried:

am new to ASP.net, couldnt get much hold on it, some people suggested to add plugins
Posted
Updated 9-Sep-16 9:29am
Comments
ZurdoDev 9-Sep-16 14:48pm    
Most calendar controls already do that.

1 solution

You could easily do it with jQuery. For example:

JavaScript
$(function () {
     $("#textbox1").datepicker();        
});


And here's a quick full example:


HTML
<html>
<head>
 <link rel="stylesheet" href="//ajax.googleapis.com/ajax/libs/jqueryui/1.11.2/themes/smoothness/jquery-ui.css" />
 <script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>
 <script src="//ajax.googleapis.com/ajax/libs/jqueryui/1.11.2/jquery-ui.min.js"></script>

<script>
 $(function () {
            $("#textbox1").datepicker({
                changeMonth: true,
                changeYear: true,
            });        
});
</script>

<body>    
<input type="text" id="textbox1" />
</body>


You can view the demo here: Edit fiddle - JSFiddle[^]

Keep in mind that jQuery is just one of the many plugins that you can use. Of course you find some other plugins that best suit your needs or use ASP.NET Calendar Extender control from AJAXControlToolkit.
 
Share this answer
 
v2
Comments
Karthik_Mahalingam 10-Sep-16 1:11am    
5
Vincent Maverick Durano 10-Sep-16 7:53am    
Thank you :)

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