What should be the format of the date fields in the loop?

kadir 60 Reputation points
2024-05-27T15:07:10.47+00:00
            @for (int i = 0; i < Model.TBL_CalismaHayatiList.Count; i++)

                                {<div class="col-md-6">

                                                    <div class="input-block mb-6">

                                                        <label class="col-form-label">Giriş Tarihi:</label>

                                                       @Html.TextBoxFor(model => model.TBL_CalismaHayatiList[i].GirisTarih, new { @class = "form-control", @id = "date" })

													   @Html.ValidationMessageFor(model => model.TBL_CalismaHayatiList[i].GirisTarih, "", new { @class = "text-danger" })

                                                    </div>

                                                </div>

                                                <div class="col-md-6">

                                                    <div class="input-block mb-6">

                                                        <label class="col-form-label">Çıkış Tarihi:</label>

                                                        @Html.TextBoxFor(model => model.TBL_CalismaHayatiList[i].CikisTarih, new { @class = "form-control", @id = "date" })

                                                        @Html.ValidationMessageFor(model => model.TBL_CalismaHayatiList[i].CikisTarih, "", new { @class = "text-danger" })

                                                        <span class="form-text text-muted">Gün/Ay/Yıl</span>

                                                    </div>

                                                </div>

                                            </div>

                                        </div>

                                    </div>

                                    <div class="row">

                                        <div class="col-md-12">

                                            <div class="input-block mb-3">

                                                <label class="col-form-label">Eklemek İstedikleriniz:</label>

                                                @Html.TextAreaFor(model => model.TBL_CalismaHayatiList[i].Notlar, new { @class = "form-control", rows = "5", cols = "5", placeholder = "Buraya yazın..." })

                                            </div>

                                        </div>

                                    </div>

                                }

models:

[DataType(DataType.Date)]

    public Nullable<System.DateTime> GirisTarih { get; set; }

    [DataType(DataType.Date)]

    public Nullable<System.DateTime> CikisTarih { get; set; }

								Hello everyone, I have a problem here on the cshtml side, that is, I can apply the date time format I want with @id = "date", but it does not work due to the for loop.
ASP.NET Core
ASP.NET Core
A set of technologies in the .NET Framework for building web applications and XML web services.
4,674 questions
ASP.NET
ASP.NET
A set of technologies in the .NET Framework for building web applications and XML web services.
3,540 questions
0 comments No comments
{count} votes

Accepted answer
  1. AgaveJoe 28,786 Reputation points
    2024-05-27T16:21:35.9366667+00:00

    Hello everyone, I have a problem here on the cshtml side, that is, I can apply the date time format I want with @id = "date",

    You are not following HTML rules. The id attribute must be unique on the page. It could be the issue if you are using a JavaScript or CSS selector.

    but it does not work due to the for loop.

    You have to tell us what "does not work" means.

    1 person found this answer helpful.

1 additional answer

Sort by: Most helpful
  1. Bruce (SqlWork.com) 68,236 Reputation points
    2024-05-27T15:47:28.25+00:00
    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.