Z
Z
z_a_p_a_r_a2018-12-20 17:55:53
JavaScript
z_a_p_a_r_a, 2018-12-20 17:55:53

ASP.Net core how to make calendar display only with month and year?

The model is created, let's say:

public class Person
    {
        public int PersonId { get; set; }
        public string Name { get; set; }
        [DataType(DataType.Date)]
        public DateTime Birthday { get; set; }
   }

VS automatically generates the following for the Birthday field:
<div class="form-group">
    <label class="control-label" for="Birthday">День рождения</label>
    <input class="form-control"  type="date" data-val="true" data-val-required="Введите день рождения" id="Birthday" name="Birthday" value="">
    <span class="text-danger field-validation-valid" data-valmsg-for="Birthday" data-valmsg-replace="true"></span>    
</div>

Now a question. It is she who creates such an input with the help of what? bootstrap? I have not seen such classes there. And how do I create the same but only that would show the month and year.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vladimir S, 2018-12-20
@z_a_p_a_r_a

somewhere in the view code or javascript you need to add / correct something like this
or

$('.datepicker').datepicker({
    format: 'mm/yyyy'
});

depending on how the client calendar is implemented.
in the model, you can only set the output and input format of the value

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question