Quantcast
Channel: Active questions tagged blazor - Stack Overflow
Viewing all articles
Browse latest Browse all 4839

Cannot convert from 'method group' to 'Microsoft.AspNetCore.Components.EventCallback'

$
0
0

I am building a Blazor Server App with .Net 6.CustomInputBase.razor file -

@inherits CustomInputBase@using System.Linq.Expressions@if (Type == "number"){<InputNumber Value="@IntValue" ValueExpression="@(() => IntValue)" class="@Class" id="@Id" ValueChanged="OnIntValueChanged" />}else if (Type == "text"){<InputText Value="@StringValue" ValueExpression="@(() => StringValue)" class="@Class" id="@Id" ValueChanged="OnStringValueChanged" />}

And this is the CustomInputBase.cs file

public class CustomInputBase : ComponentBase{    [Parameter] public string Type { get; set; }    [Parameter] public int IntValue { get; set; }    [Parameter] public EventCallback<int> IntValueChanged { get; set; }    [Parameter] public string StringValue { get; set; }    [Parameter] public EventCallback<string> StringValueChanged { get; set; }    [Parameter] public string Id { get; set; }    [Parameter] public string Class { get; set; } = "form-control";    protected async Task OnIntValueChanged(int newValue)    {        IntValue = newValue;        await IntValueChanged.InvokeAsync(IntValue);    }    protected async Task OnStringValueChanged(string newValue)    {        StringValue = newValue;        await StringValueChanged.InvokeAsync(StringValue);    }}

I am getting the error here ValueChanged="OnIntValueChanged". But OnStringValueChanged is not showing any errors.

How to solve the error?


Viewing all articles
Browse latest Browse all 4839

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>