Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/296.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# Blazor在页面加载时初始化日期 出生日期_C#_Blazor - Fatal编程技术网

C# Blazor在页面加载时初始化日期 出生日期

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

我想做的是确定日期的初始值

1/1/(本年度-60)


我似乎无法理解这一点。

我更喜欢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);
}