简体   繁体   中英

Eventcallback string not working in blazor

I have a generic text controller, please see my code below. I'm getting if (ValueChanged.HasDelegate) always false. what could be the issue that HasDelegate getting always false ? I'm expecting true value. Thanks!

 <RadzenTextBox Disabled="@(IsSaving || Disabled)" 
                       Style="width: 100%" 
                       @bind-Value=@Value 
                       Change="@(OnChange)" />

private async Task OnChange(string selectedValue)
        {
            if (String.IsNullOrEmpty(PropertyName) || String.IsNullOrEmpty(selectedValue))
                return;

            IsSaving = true;
            await DealRepository.UpdateSingleField(DealId, PropertyName, selectedValue);            
            IsSaving = false;

            if (ValueChanged.HasDelegate)
                await ValueChanged.InvokeAsync(selectedValue);          
        }


[Parameter] public EventCallback<string> ValueChanged { get; set; }

在调用通用文本控制器时,我已将 Value 更改为 @bind-Value 并且我的问题已解决。

    <RowTextBox Disabled="true" Title="Address" @bind-Value="@val" PropertyName="Test" DealId="@Id"></RowTextBox>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM