I am working with ASP.Net MVC with Jquery Date picker.
here is my model class
public class myViewModel
{
public DateTime? FromDate {get;set;}
public DateTime? ToDate {get;set;}
}
here is my View Class
@model testApp.myViewModel
@Html.TextBox("FromDate","{0:MM/dd/yyyy}", new { @class = "datepicker" })
@Html.TextBox("ToDate","{0:MM/dd/yyyy}", new { @class = "datepicker" })
and JQuery
<script>
$(function () {
$(".datepicker").datepicker({
changeMonth: true,
changeYear: true
});
});
</script>
Now the issue is whenever my page is load default date does not display in textbox instead "{0:MM/dd/yyyy}" display in both textbox
So how can I display and bind current date value in my FromDate and ToDate textbox?
Thanks
@Html.Textbox()
where the second parameter is thevalue
(to display). You may be confusing this with@Html.TextBoxFor()
where the second parameter is theformat