Reputation: 25
I am trying to implement a date picker in ASP.NET. I have included following in my section.
<script>
$(function () {
$("#cbirthdate").datepicker();
});
</script>
I want date to poput at textbox with id 'cbirthdate',
However, nothing happens when I click on date text box. Is there anything wrong I am doing?
Upvotes: 0
Views: 4786
Reputation: 1
You should do
$( document ).ready(function() {
$("#<%=cbirthdate.ClientID%>").datepicker();
});
Upvotes: 0
Reputation: 6619
If you have included all the libs for jQuery and jQuery UI correctly it should work.
Two things you could look for is that if you using ASP.NET WebForms, inspect the DOM to see that the ID of the element really is cbirthdate, click View Source in your browser.
Also you could try to attach the datepicker when the DOM is ready by this function
$( document ).ready(function() {
$("#cbirthdate").datepicker();
});
As jadarnel27 says in the comment and I thought about, is if there really is a cbirthday. Try this syntax which is a combination of both my suggestions.
$( document ).ready(function() {
$("#<%# cbirthdate.ClientID %>").datepicker();
});
Upvotes: 2
Reputation:
Add calendar extender from ajax toolkit and set the targetcontrol to the textbox control.
Upvotes: 1