Blazor在页面加载时初始化日期


<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(

我似乎想不通。

我更喜欢DateTimeOffset而不是DateTime,但想法仍然相同:

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);
}

相关内容

  • 没有找到相关文章

最新更新