for Birthday.
public DateTime Birthday { get; set; }
<input id="Birthday" name="Birthday" type="text" class="form-control">
Should you be using a text input?
I need to use text bcs of datetime input library
Is the birthday property part of your page model?
Yes its a property of my user entity
Any way to fix ?
Use the DateTime.Parse method
I'm still not entirely sure what the problem is, but I'm willing to bet it has to do with the format. I can't do much with this. Check this out, and try a few other dates, like 11/10/2020.
Where ? I'm the type in viewmodel is DateTime but in view is text
Building on @getAx response. private DateTime _birthday; public DateTime Birthday { get => _birthday; set => _birthday = DateTime.Parse(value); } Edit: I'm having doubts about this.
Looks good but how to pass it to my model ?
You should start here.
I figured something like that might happen.
how about this ? testing.. private DateTime _birthday; public string Birthday { get => _birthday.Date.ToString("dd/MM/yyyy"); set => _birthday = DateTime.ParseExact(value, "dd/MM/yyyy", CultureInfo.CurrentCulture); }
Seems like your library is making you jump through hoops just to accommodate it. My opinion is that it would be less painful to just find a proper DateTime input library.
Couldnt find a simple one also bootstrap datetime isnt working (styles not applying)
this worked tnx
Обсуждают сегодня