Click here to Skip to main content
15,881,882 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Dear All,
I am using Asp.net 4 and c# language.I need show jquery calendar control on page load i am using following code but is show when click the text box.
XML
<head>
    <link href="../assets/styles.min.css" rel="stylesheet">
    <title>jQuery UI Datepicker: Set Date on Page Load</title>
    <link href="//ajax.googleapis.com/ajax/libs/jqueryui/1.11.1/themes/ui-darkness/jquery-ui.min.css" rel="stylesheet">
    <script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
    <script src="//ajax.googleapis.com/ajax/libs/jqueryui/1.11.1/jquery-ui.min.js"></script>
</head>
<body id="date" >
    <input id="datepicker" type="text">
    <script>       
        $(function () {
            $("#datepicker").datepicker();
            $("#datepicker").datepicker("setDate", new Date);
        });
    </script>
</body>



any one help me Thanks Advance!....
Posted
Comments
Krunal Rohit 13-Oct-15 1:14am    
I assume "datepicker" is your textbox name. This is the default behaviour of datepicker, when you click on textbox that you have assigned the datepicker, it will popup. Please refer jQuery UI documentation for your query.

-KR

1 solution

This is simple just do:

JavaScript
$("#datepicker").datepicker();
$("#datepicker").datepicker("setDate", new Date());
$("#datepicker").datepicker('show');


You can also use jQuery chaining like:

JavaScript
$("#datepicker")
    .datepicker()
    .datepicker("setDate", new Date())
    .datepicker('show');


Datepicker show method[^]
 
Share this answer
 
v4
Comments
Member 11889799 13-Oct-15 1:47am    
Hi Palash Mondal,
Thanks for your Response your code is working fine in Normal page but it is not working in master page why it's not firing in master page?
Palash Mondal_ 13-Oct-15 1:59am    
Please check:
http://stackoverflow.com/questions/8534777/jquery-script-not-working-in-master-page
http://stackoverflow.com/questions/16577620/jquery-in-master-page-is-not-working
See if it helps to resolve the issue or please post a new question related to master page issue.
Member 11889799 13-Oct-15 2:20am    
Hi Palash,
Thanks now my problem is cleared.
Palash Mondal_ 13-Oct-15 2:25am    
Glad it helped!

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