Reputation: 125
<script src="<%=("../Scripts/jquery-1.6.1.min.js") %>" type="text/javascript" />
<script src="<%=("../Scripts/jquery-datePicker.js") %>" type="text/javascript" />
<script type="text/javascript">
$(function() {
$("#txtDate").datepicker();
});
</script>
I have used this code but it doesnot show me the popup calender on click on textbox. what can be the problem. it doesnot give any error.
Upvotes: 0
Views: 7506
Reputation: 13743
why not set path directly? and close script tag with this </script>
<script src="../Scripts/jquery-1.6.1.min.js" type="text/javascript" ></script>
<script src="../Scripts/jquery-datePicker.js" type="text/javascript" ></script>
Use ClientID for server control
<script type="text/javascript">
$(function() {
$("#<%= txtDate.ClientID %>").datepicker();
});
</script>
you can also use ready function
<script type="text/javascript">
$(document).ready(function() {
$("#<%= txtDate.ClientID %>").datepicker();
});
</script>
if ID selector doesn't work then use class selector it is good for ASP.NET server control
<asp:TextBox ruat="server" ID="txtDate" CssClass="DateField"></asp:TextBox>
<script type="text/javascript">
$(document).ready(function() {
$(".DateField").datepicker();
});
</script>
Upvotes: 0
Reputation: 137
ID of ASP.NET server control is different than that of the normal HTML ID. So if you are using a Server control, then run your code, open the page source, get the ID that is displayed in the page source and use this ID instead of txtDate.
Also use
$(document).ready(function() { $("#<id>").datepicker(); });
Upvotes: 0
Reputation: 270
Perhaps you should use the document.ready function
$(document).ready(function() {
$("#txtDate").datepicker();
});
Upvotes: 1