"TryParseValueFromString not implemented" even when it is

226 Views Asked by At

Below is the empty component I am working on:

DatePicker.razor

@typeparam TValue
@inherits InputBase<TValue>

<h3>DatePicker</h3>

DatePicker.razor.cs

using Microsoft.AspNetCore.Components;
using Microsoft.AspNetCore.Components.Forms;

namespace Accounting.Web.Components.Forms
{
    public partial class DatePicker<TValue> : InputBase<TValue>
    {

        protected override bool TryParseValueFromString(string? value, out TValue result, out string? validationErrorMessage)
        {
            if (BindConverter.TryConvertTo<TValue>(value, null, out result))
            {
                validationErrorMessage = "";
                return true;
            }
            else
            {
                validationErrorMessage = "Err : Select value";
                return false;
            }
        }
    }
}

Usage in Index.razor

<DatePicker Value="2023-01-01"></DatePicker>

When compiling the above code produces the followng error?

Error : 'DatePicker<TValue>' does not implement inherited abstract member 'InputBase<TValue>.TryParseValueFromString(string?, out TValue, out string?)' 

Which is confusing because TryParseValueFromString override is asyou can see present in DatePicker.razor.cs.

Where could I be going wrong?

0

There are 0 best solutions below