<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>
我想做的是拥有日期的初始值
1/1 /(当前年份-60)
我似乎无法弄清楚。
答案 0 :(得分:1)
与DateTime相比,我更喜欢使用DateTimeOffset,但是想法还是一样的:
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);
}