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

Blazor .NET 8 web app server two-way binding not binding to a model and events not being triggered

$
0
0

I'm using Syncfusion's SfTextBox component in a Blazor Server application. I have bound the @bind-Value to a property in my model and added a ValueChange event for additional logic.

However, the ValueChange event is not triggering, and the bound property remains null.

<SfTextBox @bind-value=@Value               Placeholder=@Placeholder               Enabled=@IsEnabled               FloatLabelType=@FloatLabelType.Never               CssClass="" />
public partial class SignInComponent : ComponentBase{      [Inject]      public IIdentityViewService IdentityViewService { get; set; }      [Inject]      public AuthenticationStateProvider AuthStateProvider { get; set; }      public ComponentState State { get; set; }      public IdentityComponentException Exception { get; set; }      public SignInView SignInView { get; set; }      public TextBoxBase SignInEmailTextBox { get; set; }      public TextBoxBase SignInPasswordTextBox { get; set; }      public ButtonBase SubmitButton { get; set; }      public SpinnerBase Spinner { get; set; }      protected override void OnInitialized()      {          SignInView = new SignInView();          State = ComponentState.Content;      }}
public partial class TextBoxBase : ComponentBase{     [Parameter]     public string Value { get; set; }     [Parameter]     public string Placeholder { get; set; }     [Parameter]     public string CssClass { get; set; }     [Parameter]     public EventCallback<string> ValueChanged { get; set; }     [Parameter]     public bool IsDisabled { get; set; }     public bool IsEnabled => IsDisabled is false;     public async Task SetValue(string value)     {         this.Value = value;         await ValueChanged.InvokeAsync(this.Value);     }     private Task OnValueChanged(ChangeEventArgs changeEventArgs)     {         this.Value = changeEventArgs.Value.ToString();         //InvokeAsync(StateHasChanged);         return ValueChanged.InvokeAsync(this.Value);     }     public void Disable()     {         this.IsDisabled = true;         InvokeAsync(StateHasChanged);     }     public void Enable()     {         this.IsDisabled = false;         InvokeAsync(StateHasChanged);     }}
<div class="py-6 flex flex-col gap-5"><div><TextBoxBase             @ref=@SignInEmailTextBox             @bind-Value=@SignInView.UsernameOrEmail             Placeholder="Your email ?"             CssClass="w-full py-3 px-6 ring-1 ring-gray-300 rounded-xl placeholder-gray-600 bg-transparent transition disabled:ring-gray-200 disabled:bg-gray-100 disabled:placeholder-gray-400 invalid:ring-red-400 focus:invalid:outline-none" /></div><div class="flex flex-col items-end"><TextBoxBase              @ref=@SignInPasswordTextBox             @bind-Value=@SignInView.Password             Placeholder="What's the secret word ?"             CssClass="w-full py-3 px-6 ring-1 ring-gray-300 rounded-xl placeholder-gray-600 bg-transparent transition disabled:ring-gray-200 disabled:bg-gray-100 disabled:placeholder-gray-400 invalid:ring-red-400 focus:invalid:outline-none" /><a href="/forgotten/password" type="reset" class="w-max p-3 -mr-3"><span class="text-sm tracking-wide text-blue-600">Forgot password ?</span></a></div><div><ButtonBase                @ref=@SubmitButton                OnClick=@SignInAsync                Label="Login"               CssClass="w-full px-6 py-3 rounded-xl bg-sky-500 transition hover:bg-sky-600 focus:bg-sky-600 active:bg-sky-800" /><SpinnerBase @ref=@Spinner /></div></div>

Viewing all articles
Browse latest Browse all 4839

Trending Articles



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