C# Blazor在页面加载时初始化日期 出生日期
我想做的是确定日期的初始值 1/1/(本年度-60)C# Blazor在页面加载时初始化日期 出生日期,c#,blazor,C#,Blazor,我想做的是确定日期的初始值 1/1/(本年度-60) 我似乎无法理解这一点。我更喜欢DateTimeOffset而不是DateTime,但想法仍然是一样的: <div class="wrap-input100 validate-input"> <span class="label-input100">Date of Birth</span> <InputDate class="input1
我似乎无法理解这一点。我更喜欢DateTimeOffset而不是DateTime,但想法仍然是一样的:
<div class="wrap-input100 validate-input">
<span class="label-input100">Date of Birth</span>
<InputDate class="input100" id="birthday" name="birthday" @bind-Value="CurrentCustomerSubmission.DateOfBirth" max="@DateTime(DateTime.Now.Year-60,1,1).ToString()" />
<ValidationMessage For="@(() => CurrentCustomerSubmission.DateOfBirth)" />
</div>
您在哪里初始化当前客户子任务?
override protected void OnInitialized() // Where ever you are initialising your CurrentCustomer Submission
{
CurrentCustomerSubmission = new Customer();
CurrentCustomerSubmission.DateOfBirth = new DateTime(DateTime.Now.Year - 60, 1, 1);
}