Reputation: 1335
How do we make the date to appear in the textbox on the click of an image button using jquery and ASP.NET?
Upvotes: 3
Views: 23752
Reputation: 2045
Please try like below code with class selector, know to more detail click on jQuery Date Picker
<asp:TextBox ID="txtFromDate" CssClass="From-Date" runat="server"></asp:TextBox>
<script language="javascript" type="text/javascript">
jQuery('.From-Date').datepicker({
showOn: "button",
buttonText: "Select Date",
buttonImage: "images/calendar.png",
buttonImageOnly: true
}
});
</script>
Upvotes: 3
Reputation: 6130
Try this:
<script language="javascript" type="text/javascript">
$(document).ready(function(){
$("#<%= txtDate.ClientID %>").datepicker({
showOn: "button",
buttonImage: generateURL("/Images/Calendar.jpg"),
buttonImageOnly: true
});
});
</script>
<asp:TextBox ID="txtDate" runat="server"></asp:TextBox>
Upvotes: 0
Reputation: 17614
Here is a good example which may help you to use it.
http://www.codeproject.com/Articles/47474/ASP-NET-Control-from-jQuery-DatePicker-in-3-Minute
You should check out the jQuery UI DatePicker.
ASP.NET Example
<script>
$(function() {
$( "#<%= txtDate.ClientID %>" ).datepicker();
});
</script>
<form id="form1" runat="server">
<div>
<asp:TextBox ID="txtDate" runat="server" />
</div>
</form>
If you want to show button
Go through this linke
How I can use JQuery Datepicker with a Icon and a Format in ASP.NET
Which suggest you to use like
$(".txtVon").datepicker({
showOn: "button",
buttonImage: "images/calendar.gif",
buttonImageOnly: true
});
Upvotes: 4