Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
169
rated 0 times [  176] [ 7]  / answers: 1 / hits: 20040  / 10 Years ago, fri, august 29, 2014, 12:00:00

I found a similar question here but that do not work for my case. Please look at the screen shot below. When I render data in an Edit form, all data was set to the controls properly except the highlighted date field. When I inspect the element, I found that the value is there but for some reason it is not showing in the field.



Here is the code I used to set value into this date field. I tried both yyyy-MM-dd & MM/dd/yyyy format but none worked.



<td>Joining Date</td>
<td>
@{
if(Model.JoiningDate != null)
{
<input id=txtJoiningDate type=date style=width: 100%; [email protected]({0:MM/dd/yyyy},Model.JoiningDate.Value) />
}
else
{
<input id=txtJoiningDate type=date style=width: 100%; />
}
}
</td>


enter



Edit

enter


More From » asp.net-mvc

 Answers
8

Why instead you just use html helper as shown :-



@Html.TextBox(txtJoiningDate, Model.JoiningDate.Value ,{0:yyyy-MM-dd},new{ @style=width:100%, type=date })

[#69620] Tuesday, August 26, 2014, 10 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
markusdamienn

Total Points: 167
Total Questions: 119
Total Answers: 93

Location: Oman
Member since Wed, Apr 12, 2023
1 Year ago
;