I'm using date picker in my component to bind the value to my method in blazor. the value is always empty.
Here is my component :
<input data-provide="datepicker" class="col-sm-2 form-control" @bind="date_selected" data-date-format="yyyy-mm-dd"
style="width: 300x ;height:35px;">
code{
string date_selected;
public async Task GetTags()
{
AllTags = await Task.Run(() => tagsService.Map( date_selected));
}
}
my java script :
$( document ).ready(function() {
$("#from-datepicker").datepicker({
format: 'yyyy-mm-dd HH:mm:ss'
});
$("#from-datepicker").on("change", function () {
var fromdate = $(this).val();
alert(fromdate);
});
});
Do you have any idea why I can't get the values and how can I solve it ?
I'm not sure what you're trying to achieve, but I suppose you can do it with pure Blazor. Maybe something like:
<input type="date" @onchange=HandledateChange />
<div>You selected: @date</div>
@code {
string date = "";
async Task HandledateChange(ChangeEventArgs args)
{
date = args.Value.ToString();
}
}