My current code looks like this:
@if(IsPost)
{
<input class="form-control" type="date" id="selDay" name="selDay" value="@(Request.Form["selDay"])" />
}
else
{
<input class="form-control" type="date" id="selDay" name="selDay" />
}
When I insert a breakpoint and check the value being passed, it is correct. The selected date is passed as the value for the input, but it is not being saved. The default value is today's date (when the page loads for first time). Even after submit, the date shows as today's date.
I also tried
value="javascript:keepDate();"
<script>
function keepDate() {
var date = document.getElementById("selDay");
return date.value;
}
</script>
I want to retain the selected date after the page reloads, and keep that selected date. I'm using asp.net mvc4 if that matters.
*I don't need to retain the its value when it is disabled and has default value. I only need this when it is enabled and the user changes the date (I need to retain the new changed date.)