@page "/"
<h1>Example Datetime in Blazor</h1>
<h2>Last date of Month</h2>
<div class="wrapper">
<form>
<div class="form-group">
<label>Date </label>
<input id="txtDate" type="date" required @bind-value="_precio.Fecha_Inicio" />
</div>
<div class="form-group">
<label>Date (last date of Month)</label>
<input id="txtDate" type="date" required @bind-value="_precio.Fecha_Final" />
</div>
</form>
</div>
@code{
private Precio _precio;
protected override void OnInitialized()
{
_precio = new Precio();
_precio.Fecha_Inicio = DateTime.Today;
}
public class Precio {
private DateTime _fechaInicio;
public DateTime Fecha_Inicio {
get {
return _fechaInicio;
}
set {
_fechaInicio = value;
Fecha_Final = new DateTime(value.Year, value.Month, 1).AddMonths(1).AddDays(-1);
}
}
public DateTime Fecha_Final { get; set; }
}
}